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

Working with internal table issue

Former Member
0 Likes
1,167

Hi all

i have internal table with the follwing data

and i want to move the entries (FNAM ,FVAL ) that relate to one screen 0101

into new table and the entries for the new screen 7101 to diffrent table

program        dynpro   dynbegin  fnam            fval

SAPMF02D	0101	X
	0000		          BDC_CURSOR	  RF02D-D0110
	0000		          BDC_OKCODE	  /00
	0000		          RF02D-KUNNR	  1000
	0000		          RF02D-D0110	  X
SAPMF02D	7101	X
	0000		          BDC_OKCODE	  /EF12
	0000		          BDC_CURSOR	  RF02D-KUNNR

I want in table 1 for screen 0101

fnam            fval
BDC_CURSOR	  RF02D-D0110
BDC_OKCODE	  /00
RF02D-KUNNR	  1000
RF02D-D0110	  X

and in table 2 screen 7101

BDC_OKCODE	  /EF12
BDC_CURSOR	  RF02D-KUNNR

what is the best way to do that assume the tables content can

be change i.e. have more screens.

Best regards

Alex

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,110

A suggestion/sample on how to build an internal table of internal tables associated to the dynpros of the batch input :

TYPES: BEGIN OF dynpros,
         program LIKE bdcdata-program,
         dynpro LIKE bdcdata-dynpro,
         bdcdata LIKE bdcdata OCCURS 0,
       END OF dynpros.

DATA: i_data TYPE TABLE OF bdcdata,
      e_data TYPE TABLE OF dynpros.

FIELD-SYMBOLS: <f1> TYPE bdcdata,
               <f2> TYPE dynpros.

LOOP AT i_data ASSIGNING <f1>.
  IF <f1>-program IS NOT INITIAL
  OR <f1>-dynpro IS NOT INITIAL.
    READ TABLE e_data ASSIGNING <f2>
      WITH KEY program = <f1>-program
               dynpro = <f1>-dynpro.
    IF sy-subrc NE 0.
      APPEND INITIAL LINE TO e_data ASSIGNING <f2>.
      <f2>-program = <f1>-program.
      <f2>-dynpro = <f1>-dynpro.
    ENDIF.
    APPEND <f1> TO <f2>-bdcdata.
  ENDIF.
ENDLOOP.

Regards,

Raymond

10 REPLIES 10
Read only

former_member201275
Active Contributor
0 Likes
1,110

I have created some simple pseudo code... may help you:

LOOP AT itab ASSIGNING <fs_line>.

CASE <fs_line>-dynpro.

WHEN '0101'.

flag_0101 = abap_true.

flag_7101 = abap_false.

WHEN '0101'.

flag_0101 = abap_false.

flag_7101 = abap_true.

WHEN space.

IF flag_0101 = abap_true.

... code to move entries to 0101 itab...

ENDIF.

IF flag_7101 = abap_true.

... code to move entries to 7101 itab...

ENDIF.

WHEN OTHERS.

CLEAR: flag_0101, flag_7101.

ENDCASE.

ENDLOOP.

<removed by moderator>

Edited by: Thomas Zloch on Aug 16, 2010 2:12 PM - please do not ask for ...

Read only

0 Likes
1,110

HI Gemini Twin

Thanks but the problem here is that you refer

to the screen like hardcoded screen 0101 7101 and this is the simple

case i wont a generic solution since the screen num can be change

to 200 300 etc

best regards

Alex

Read only

0 Likes
1,110

At some point you will have to know the screen number you are dealing with, otherwise how would you knwo where to move the values to? Not sure how else you could do this then.

Read only

0 Likes
1,110

HI

There is no way to do that?

best regards

Alex

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,111

A suggestion/sample on how to build an internal table of internal tables associated to the dynpros of the batch input :

TYPES: BEGIN OF dynpros,
         program LIKE bdcdata-program,
         dynpro LIKE bdcdata-dynpro,
         bdcdata LIKE bdcdata OCCURS 0,
       END OF dynpros.

DATA: i_data TYPE TABLE OF bdcdata,
      e_data TYPE TABLE OF dynpros.

FIELD-SYMBOLS: <f1> TYPE bdcdata,
               <f2> TYPE dynpros.

LOOP AT i_data ASSIGNING <f1>.
  IF <f1>-program IS NOT INITIAL
  OR <f1>-dynpro IS NOT INITIAL.
    READ TABLE e_data ASSIGNING <f2>
      WITH KEY program = <f1>-program
               dynpro = <f1>-dynpro.
    IF sy-subrc NE 0.
      APPEND INITIAL LINE TO e_data ASSIGNING <f2>.
      <f2>-program = <f1>-program.
      <f2>-dynpro = <f1>-dynpro.
    ENDIF.
    APPEND <f1> TO <f2>-bdcdata.
  ENDIF.
ENDLOOP.

Regards,

Raymond

Read only

0 Likes
1,110

HI Raymond

Thanks for replay

I try your code with little adjustment

TYPES: BEGIN OF dynpros,

program TYPE bdcdata-program,

dynpro TYPE bdcdata-dynpro,

bdcdata TYPE hrtb_bdcdata , <-- change it to table for the append statment APPEND <f1> TO <f2>-bdcdata.

END OF dynpros.

and what i get in e_data is :

E_DATA

SAPMF02D 0101 Standard Table[1x5(618)]

SAPMF02D 7101 Standard Table[1x5(618)]

this is not really what i need

i want to get all the FNAM and FVAL from the table like this

I want in table 1 for screen 0101

fnam fval

BDC_CURSOR	  RF02D-D0110

BDC_OKCODE	  /00

RF02D-KUNNR	  1000

RF02D-D0110	  X

and in table 2 screen 7101

BDC_OKCODE	  /EF12

BDC_CURSOR	  RF02D-KUNNR

Best Regards

Alex

Read only

0 Likes
1,110

Define a local table type for e_data-bdcdata, with only fields fnam and fval, and only append if those are not initial. Your first result internal table will be e_data[1]-bdcdata, etc.

Regards,

Raymond

Read only

0 Likes
1,110

HI Raymond

Thaks again

it try to do your suggestion and its not work

any differnt suggestion?

Thanks in Advance

Alex

Read only

0 Likes
1,110

Hi, alex,

Did you take a look into the BAPI's : BAPI_CUSTOMER_CREATE,

BAPI_CUSTOMER_EDIT ?

Regards, Sebastiá

Read only

0 Likes
1,110

HI ,

I know this Bapi's but how they should help me?

Regards

Alex