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: 

Doubt Regarding Internal Table

Former Member
0 Kudos

I don't have much ABAP experience. I want to convert records in a BW datapak to a new account number scheme, which is contained in a database table.

Is this the most efficient way to do it?

Also, I am particularly concerned about the modify statement, is it only modifying the one line, or is it modifying the whole datapak table?

Thanks for any help.


PROGRAM CONVERSION_ROUTINE.

TYPES: BEGIN OF TRANSFER_STRUCTURE ,
    record      TYPE rsarecord,
    CHART_OF_ACCTS TYPE P,
    SEGMENT1(000025) TYPE C,
    SEGMENT2(000025) TYPE C,
    SEGMENT3(000025) TYPE C,
END OF TRANSFER_STRUCTURE .

TYPES: TAB_TRANSTRU type table of TRANSFER_STRUCTURE.

DATA: WA LIKE /BIC/AZORA_O_N00,
      ITAB TYPE STANDARD TABLE OF /BIC/AZORA_O_N00 WITH HEADER LINE.


FORM STARTROUTINE
  USING    G_S_MINFO TYPE RSSM_S_MINFO
  CHANGING DATAPAK type TAB_TRANSTRU
           G_T_ERRORLOG TYPE rssm_t_errorlog_int
           ABORT LIKE SY-SUBRC.
  DATA: l_s_datapak_line type TRANSFER_STRUCTURE,
        l_s_errorlog TYPE rssm_s_errorlog_int.

  SELECT *
  INTO   CORRESPONDING FIELDS OF TABLE ITAB
  FROM   /BIC/AZORA_O_N00.

  LOOP AT DATAPAK INTO L_S_DATAPAK_LINE.
    READ TABLE ITAB WITH KEY
                 SOURSYSTEM = 'OR'
                 ORA_COAID = L_S_DATAPAK_LINE-CHART_OF_ACCTS
                 ORA_CCTR = L_S_DATAPAK_LINE-SEGMENT2
                 ORA_ACCNT = L_S_DATAPAK_LINE-SEGMENT3.

    IF SY-SUBRC = 0.
      L_S_DATAPAK_LINE-SEGMENT2 = ITAB-/BIC/ZORA_CCTR.
      L_S_DATAPAK_LINE-SEGMENT3 = ITAB-/BIC/ZORA_ACCT.
      MODIFY DATAPAK FROM L_S_DATAPAK_LINE.
    ENDIF.
  ENDLOOP.

  ABORT = 0.
ENDFORM.

<b></b><b></b><b></b>

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

It looks ok to me, the modify statement will look at the "key" of the record that you are trying to update and modfiy that line of the itab.

Regards,

Rich Heilman

9 REPLIES 9

andreas_mann3
Active Contributor
0 Kudos

Hi Jerry,

in your coding statement "MODIFY DATAPAK FROM L_S_DATAPAK_LINE." is in a loop.

so all records of "DATAPAK", which are found in migration-table "ITAB" are modified.

regards Andreas

Former Member
0 Kudos

U can convert the select to -

SELECT * INTO CORRESPONDING FIELDS OF TABLE ITAB FROM /BIC/AZORA_O_N00

for all entries in DATAPAK

where ORA_COAID = DATAPAK_LINE-ACCTS AND

ORA_CCTR = DATAPAK_LINE-SEGMENT2 AND

ORA_ACCNT = DATAPAK_LINE-SEGMENT3

AND SOURSYSTEM = 'OR'.

This will result in less number of entries in ITAB.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

It looks ok to me, the modify statement will look at the "key" of the record that you are trying to update and modfiy that line of the itab.

Regards,

Rich Heilman

Vinod_Chandran
Active Contributor
0 Kudos

The way you are doing is good.

In this case only one record of DATAPACK will be modified at a time depends on the value from L_S_DATAPAK_LINE.

Former Member
0 Kudos

Hi Jerry,

Just add this lines(Transporting) also in the modify statement to make it more efficient.This modify statement would modify the whole datapak table if the read statement pacifies.

IF SY-SUBRC = 0.

L_S_DATAPAK_LINE-SEGMENT2 = ITAB-/BIC/ZORA_CCTR.

L_S_DATAPAK_LINE-SEGMENT3 = ITAB-/BIC/ZORA_ACCT.

MODIFY DATAPAK FROM L_S_DATAPAK_LINE TRANSPORTING /BIC/ZORA_CCTR /BIC/ZORA_ACCT .

ENDIF.

Regards

Abhishek

0 Kudos

It seems a little redundant and wasteful to read the datapak line by line, but then update the entire datapak, because there will be multiple rows that need converting to the same value.

It doesn't seem to impact performance, I am just wondering if there is a neater way of doing it.

Thanks for all the replies.

0 Kudos

Please remember to award points for helpful answers. Thanks.

Regards,

Rich Heilman

0 Kudos

it's o.k , you've to convert every line.

regards Andreas

0 Kudos

Sure will award points. It seems to limit me on how many "very helpful answers" I can give.