Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

update

Former Member
0 Likes
492

Hi all,

I have one flat file which i am uploading into custom table.

It consists of three record type record type 1,

Record type 2

Record type 3.

In record type 3 there is one field for customer description

Now by code for single record type 3 the table is getting updated with customer description

But the actuall requirement is if there are 10 records of type 3 for which we will have ten customerd escriptions

All these descriptions has to be concatenated into the field and the table has to be updated.

Can u suggest the code..

1 ACCEPTED SOLUTION
Read only

suresh_datti
Active Contributor
0 Likes
464

something along these lines..

data: w_cust_desc type string.
loop at t_file where rec_type eq 3.
concatenate w_cust_desc t_file-rec into w_cust_desc
  separated by space.
endloop.

~Suresh

3 REPLIES 3
Read only

suresh_datti
Active Contributor
0 Likes
465

something along these lines..

data: w_cust_desc type string.
loop at t_file where rec_type eq 3.
concatenate w_cust_desc t_file-rec into w_cust_desc
  separated by space.
endloop.

~Suresh

Read only

0 Likes
464

Suresh thank you.

and one more requirement is there may be multiple 2 type records .

all these records should also get updated .

the flat file may be like

1-header

22222222222

22222222222

22222222222

33333333333

33333333333

33333333333

33333333333.

all the records has to get updated in the ztable.

below is the code i wrote.

TABLES: Ztable.

  • Work fields

DATA: W_DATE(8) TYPE C,

W_SEQNUM(10) TYPE C,

W_CNUM LIKE Ztable-ZCNUM,

W_FLAG TYPE C VALUE 0.

  • Structures

  • Internal tables

DATA: BEGIN OF T_DATA OCCURS 0,

FLD(2350),

END OF T_DATA.

DATA: T_CDATA LIKE Ztable OCCURS 0 WITH HEADER LINE,

W_DATA LIKE Ztable,

W_REC LIKE Ztable,

W_SREC LIKE SY-SUBRC,

W_EREC LIKE SY-SUBRC,

W_TREC LIKE SY-SUBRC.

  • To collect error messages

DATA : BEGIN OF IT_ERR OCCURS 0,

BUKRS LIKE Ztable-BUKRS,

ZCNUM LIKE Ztable-ZCNUM,

BUDAT LIKE Ztable-BUDAT,

XBLNR LIKE Ztable-XBLNR,

WRBTR LIKE Ztable-WRBTR,

SAKNR LIKE Ztable-SAKNR,

KOSTL LIKE Ztable-KOSTL, MESSAGE(60),

END OF IT_ERR.

DATA : W_CON1(40),

W_CON2(250).

----


  • PARAMETERS *

----


SELECTION-SCREEN BEGIN OF BLOCK A_SELECTION WITH FRAME TITLE TEXT-000.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME. " File path

SELECTION-SCREEN END OF BLOCK A_SELECTION.

----


  • AT SELECTION SCREEN *

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

  • Allow user to select the file

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_FILENAME = ' '

DEF_PATH = 'C:\'

MASK = ',.,..'

MODE = 'O'

TITLE = 'Choose A File'

IMPORTING

FILENAME = P_FILE

EXCEPTIONS

INV_WINSYS = 1

NO_BATCH = 2

SELECTION_CANCEL = 3

SELECTION_ERROR = 4

OTHERS = 5.

----


  • START-OF-SELECTION

----


START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = P_FILE

FILETYPE = 'ASC'

TABLES

DATA_TAB = T_DATA

EXCEPTIONS

CONVERSION_EROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10.

IF SY-SUBRC <> 0.

MESSAGE E701(BC) WITH 'Error while uploading file'.

ELSE.

SELECT * FROM Ztable

INTO TABLE T_CDATA.

ENDIF.

  • Lock table

CALL FUNCTION 'ENQUEUE_Eztable'

EXPORTING

MODE_ztable = 'E'

MANDT = SY-MANDT

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE E701(BC) WITH 'Custom Table Locked'.

ENDIF.

LOOP AT T_DATA.

IF T_DATA-FLD+1(1) = '1'.

IF W_FLAG = 1.

PERFORM UPLOAD.

endif.

CLEAR : W_REC,W_DATA.

  • Client

W_DATA-MANDT = SY-MANDT.

W_DATA-ZCNUM = T_DATA-FLD+40(19).

W_CNUM = W_DATA-ZCNUM. "DV1K931125

CONCATENATE T_DATA-FLD65(4) T_DATA-FLD59(2)

T_DATA-FLD+62(2)

INTO W_DATA-BLDAT.

W_DATA-ZCNAME = T_DATA-FLD+79(45).

  • Posting Date

CONCATENATE T_DATA-FLD175(4) T_DATA-FLD169(2)

T_DATA-FLD+172(2)

INTO W_DATA-BUDAT.

  • Currency

W_DATA-WAERS = 'USD'.

  • Ref. document number

W_DATA-XBLNR = T_DATA-FLD+179(16).

W_CON1 = T_DATA-FLD+219(40).

CONDENSE W_CON1.

W_DATA-ZSUPNAME = W_CON1.

W_CON2 = T_DATA-FLD+2051(250).

CONDENSE W_CON2.

W_DATA-ZCARDCOM = W_CON2.

W_REC = W_DATA.

ENDIF.

IF T_DATA-FLD+1(1) = '2'.

  • Company Code

  • w_data-bukrs = t_data-fld+577(4).

W_DATA-BUKRS = T_DATA-FLD+97(4). "Acct field1

W_SEQNUM = T_DATA-FLD+69(10).

  • Document type

IF T_DATA-FLD79(1) = ''.

W_DATA-BLART = 'KR'.

ELSE.

W_DATA-BLART = 'KG'.

ENDIF.

  • Amount

W_DATA-WRBTR = T_DATA-FLD+80(15).

  • G/L Account

  • w_data-saknr = t_data-fld+1065(6).

W_DATA-SAKNR = T_DATA-FLD+177(6). "Acct field3

  • Cost center

  • w_data-kostl = t_data-fld+826(6).

W_DATA-KOSTL = T_DATA-FLD+137(6). "Acct field2

W_DATA-ZIORDNUM = T_DATA-FLD+217(40). "internal order Num

W_DATA-ZCNAME = W_REC-ZCNAME.

W_FLAG = 1.

ENDIF.

IF T_DATA-FLD+1(1) = '3'.

IF T_DATA-FLD+40(19) EQ W_CNUM AND

T_DATA-FLD+69(10) EQ W_SEQNUM.

W_DATA-ZMARDESC = T_DATA-FLD+359(80).

ENDIF.

W_FLAG = 1.

ENDIF.

ENDLOOP.

IF W_FLAG = 1.

PERFORM UPLOAD.

endif.

  • Unlock table

CALL FUNCTION 'DEQUEUE_Eztable'

EXPORTING

MODE_ztable = 'E'

MANDT = SY-MANDT.

END-OF-SELECTION.

----


  • FORM upload *

----


  • ........ *

----


FORM UPLOAD.

W_FLAG = 0.

W_TREC = W_TREC + 1.

READ TABLE T_CDATA WITH KEY ZCNUM = W_DATA-ZCNUM

SAKNR = W_DATA-SAKNR

KOSTL = W_DATA-KOSTL

BUDAT = W_DATA-BUDAT

WRBTR = W_DATA-WRBTR

XBLNR = W_DATA-XBLNR

BLDAT = W_DATA-BLDAT.

IF SY-SUBRC NE 0.

ztable = W_DATA.

INSERT ztable.

IF SY-SUBRC = 0.

COMMIT WORK.

W_SREC = W_SREC + 1.

ELSE.

W_EREC = W_EREC + 1.

MOVE-CORRESPONDING W_DATA TO IT_ERR.

IT_ERR-MESSAGE = TEXT-003.

APPEND IT_ERR. CLEAR IT_ERR.

ENDIF.

ELSE.

W_EREC = W_EREC + 1.

  • Columns heading

MOVE-CORRESPONDING W_DATA TO IT_ERR.

IT_ERR-MESSAGE = TEXT-004.

APPEND IT_ERR. CLEAR IT_ERR.

ENDIF.

ENDFORM.

could you please suggest.

regards,

siri.

Message was edited by:

sireesha yalamanchili

Read only

0 Likes
464

could someone plz suggest.

regards,

siri.