Application Development 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: 

Regarding spliting of the data in the internal table fields

Former Member
0 Kudos

TYPES :BEGIN OF X_flat_file,

banks LIKE lfbk-banks,

bankl LIKE lfbk-bankl,

bankn LIKE lfbk-bankn,

koinh LIKE lfbk-koinh,

bkont LIKE lfbk-bkont,

END OF X_flat_file.

DATA: t_itab TYPE STANDARD TABLE OF X_flat_file INITIAL SIZE 0,

wa_itab TYPE X_flat_file,

Now data in internal table is as follows:

t_itab-banks is AD,DE, AB

t_itab-bankl is 123456578,123456588,123456579

t_itab-bankn is 12345666,12345677,12345688

t_itab-koinh is vinod1,vinod2,vinod3

t_itab-bkont is 01,01,01

TYPES :BEGIN OF X_banks1,

banks LIKE lfbk-banks,

bankl LIKE lfbk-bankl,

bankn LIKE lfbk-bankn,

koinh LIKE lfbk-koinh,

bkont LIKE lfbk-bkont,

END OF X_banks1.

DATA: T_BANKS1 TYPE STANDARD TABLE OF X_BANKS1 INITIAL SIZE 0,

WA_BANKS1 TYPE X_BANKS1,

Now i want internal table t_itab data should split at commas and transfered to internal table t_banks1.

ex : t_itab-banks is AD,DE, AB should transfered to

t_banks: AD ( 1 record)

DE (2 record)

AB ( 3 record).

I used following coding ......

SPLIT wa_itab-BANKS AT ',' INTO T_BANKS1-BANKS.

SPLIT wa_itab-BANKL AT ',' INTO TABLE T_BANKS1-BANKL.

SPLIT wa_itab-BANKN AT ',' INTO TABLE T_BANKS1-BANKN.

SPLIT wa_itab-KOINH AT ',' INTO TABLE T_banks1-KOINH.

SPLIT wa_itab-BKONT AT ',' INTO TABLE T_BANKS1-BKONT.

SPLIT wa_itab-BANKA AT ',' INTO TABLE T_BANKA1-BANKA.

But its not working.

3 REPLIES 3

Former Member
0 Kudos

Hi

This is the 5th question from morning.. Close the other posts and then ask a question here.

Regards,

Vishwa.

Former Member
0 Kudos

Hi Manoj,

First of all you need to loop on each internal table if there are multiple records. But if there is only one record then you can use READ statement, Secondly you need to declare as my variable fields as they are separated with comma.

Example: t_itab-banks is AD,DE, AB

DATA: Field1(25)   TYPE C,
          Field2(25)    TYPE C,
          Field3(25)    TYPE C. 

Read   table t_itab-banks   into wa_itab index 1. (if there is only one record)
SPLIT wa_itab AT ',' INTO Field1 Field2 Field3.

Please close the thread once you get the ans.

Regards,

Sarvesh

0 Kudos

Dear Sarvesh,

I have closed all the previous threads and only this one is open.

My coding is like this.

DATA:X(2),N(2) TYPE N.

N = 0.

LOOP AT T_BANKS INTO WA_BANKS.

N = N + 1.

ENDLOOP.

X = 1.

perform bdc_dynpro using 'SAPMF02K' '0130' 'X'.

CNT = 1.

DO N TIMES.

IF CNT > 5.

perform bdc_field using 'BDC_OKCODE' '=P+'. "*LOGIC FOR EXTENDING TABLE CONTROL

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'BDC_CURSOR' 'BANKNAM(01)'.

CNT = 1.

ENDIF.

LOOP AT T_BANKS INTO WA_BANKS FROM X TO X.

CONCATENATE 'LFBK-BANKS(' CNT ')' INTO FLD.

perform bdc_field using FLD wa_BANKS-BANKS.

ENDLOOP.

LOOP AT T_BANKL INTO WA_BANKL FROM X TO X.

CONCATENATE 'LFBK-BANKL(' CNT ')' INTO FLD.

perform bdc_field using FLD wa_BANKL-BANKL.

ENDLOOP.

LOOP AT T_BANKN INTO WA_BANKN FROM X TO X.

CONCATENATE 'LFBK-BANKN(' CNT ')' INTO FLD.

perform bdc_field using FLD wa_BANKN-BANKN.

ENDLOOP.

LOOP AT T_KOINH INTO WA_KOINH FROM X TO X.

CONCATENATE 'LFBK-KOINH(' CNT ')' INTO FLD.

perform bdc_field using FLD wa_KOINH-KOINH.

ENDLOOP.

LOOP AT T_BKONT INTO WA_BKONT FROM X TO X.

CONCATENATE 'LFBK-BKONT(' CNT ')' INTO FLD.

perform bdc_field using FLD wa_BKONT-BKONT.

ENDLOOP.

perform bdc_field using 'BDC_CURSOR' 'LFBK-bkont'.

perform bdc_field using 'BDC_OKCODE' '=BANK'.

perform bdc_dynpro using 'SAPLBANK' '0100' 'X'.

LOOP AT T_BANKA INTO WA_BANKA FROM X TO X.

CONCATENATE 'BNKA-BANKA(' CNT ')' INTO FLD.

perform bdc_field using FLD wa_BANKA-BANKA.

ENDLOOP.

perform bdc_field using 'BDC_CURSOR' 'BNKA-BANKA'.

perform bdc_field using 'BDC_OKCODE' '=ENTR'.

CNT = CNT + 1.

X = X + 1.

ENDDO.

My problem is that first table control data is getting loaded in the table fields BANKS, BANKL, BANKN, KOINH, BKONT . But next screen ('SAPLBANK' '0100' 'X'.) is not getting called and BANKA data is not getting filled..

Pls help.

As per the recording, first BANKS, BANKL, BANKN, KOINH, BKONT table control data should be filled and next screen should be called and then BANKA data should be filled and again cursor should come back to screen ('SAPMF02K' '0130' 'X'.).

similarly second table control data.