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 internal table

Former Member
0 Likes
1,016

Hi,

I have an internal table, the structure are

TYPES: BEGIN OF T_LIST_DATA,

EBELN TYPE EKKO-EBELN, "Purchasing Document Number(10)

EBELP TYPE EKPO-EBELP, "Item# of Purchasing Document(5)

EMATN TYPE EKPO-EMATN, "Material number(18)

MENGE TYPE EKPO-MENGE, "Purchase order quantity(13)

MEINS TYPE EKPO-MEINS, "Order Unit(3)

TXZ01 TYPE EKPO-TXZ01, "Material Text(40)

NAME1 TYPE LFA1-NAME1, "Vendor Name(35)

BANFN TYPE EKET-BANFN, "Purchase requisition number(10)

END OF T_LIST_DATA.

DATA: GT_LIST_DATA TYPE T_LIST_DATA OCCURS 0 WITH HEADER LINE.

For the first query, i will select all the fields from table of EKPO and LFA1 except BANFN

SELECT ... from ekpo inner join lfa1 on... INTO TABLE GT_LIST_DATA

Currently i facing a problem, i don't know how to update the field of BANFN of GT_LIST_DATA, the data will get from another query. Thanks!

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
978

You could loop at the internal table and do the select query inside, then modify it.

Loop at GT_LIST_DATA .

* Select query and fill the field BANFN.
Modify GT_LIST_DATA .

endloop.

Or you could do one select and use FOR ALL ENTRIES in GT_LIST_DATA, then Loop the table and do a READ against it to fill the GT_LIST_DATA table.

Regards,

RIch Heilman

8 REPLIES 8
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
979

You could loop at the internal table and do the select query inside, then modify it.

Loop at GT_LIST_DATA .

* Select query and fill the field BANFN.
Modify GT_LIST_DATA .

endloop.

Or you could do one select and use FOR ALL ENTRIES in GT_LIST_DATA, then Loop the table and do a READ against it to fill the GT_LIST_DATA table.

Regards,

RIch Heilman

Read only

0 Likes
978

I use the code as follow, but it can't work. I can see the GV_LAST_PR value, but without any effect for GT_LIST_DATA, Thanks!

LOOP AT GT_LIST_DATA.

PERFORM GET_LAST_PR.

GT_LIST_DATA-BANFN = GV_LAST_PR.

MODIFY GT_LIST_DATA .

ENDLOOP.

Read only

0 Likes
978

It should work fine, make sure that GV_LAST_PR is defined exactly like GT_LIST_DATA-BANFN

Regards,

RIch Heilman

Read only

0 Likes
978

Please try by making the following changes:

DATA: TABIX LIKE SY-TABIX.
LOOP AT GT_LIST_DATA.
   TABIX = SY-TABIX.
   PERFORM GET_LAST_PR.
   GT_LIST_DATA-BANFN = GV_LAST_PR.
   MODIFY GT_LIST_DATA  INDEX TABIX TRANSPORTING BANFN.
ENDLOOP.

Regards

Eswar

Read only

0 Likes
978

Yeah, It's work, i made some mistake before. Thanks

Beside, it is a typical way to update the internal table?

Read only

0 Likes
978

My example is the most basic way.

Regards,

Rich Heilman

Read only

0 Likes
978

You might consider rewarding points for helpful answers. Thanks.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
978

Hi

We can directly get the PR number from table EKPO.

If you are extracting from EKET, you can still include this in the join of the extraction.

From other source, proceed as below:

LOOP AT GT_LIST_DATA INTO <WA>.
      READ TABLE IT_EKET INTO WA_EKET WITH KEY EBELN = <WA>-EBELN
                         EBELP = <WA>-EBELP.
      IF SY-SUBRC EQ 0.
          <WA>-BANFN = WA_EKET-BANFN.
          MODIFY GT_LIST_DATA FROM <WA> TRANSPORTING BANFN.
      ENDIF.
ENDLOOP.

Kind Regards

Eswar