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: 

internal table

Former Member
0 Kudos

i_tab

Parameters Sample data

MATERIAL abcd

PLANT Get from PO line item in SAP

STGE Get from PO line item in SAP

MOVE_TYPE 101

ENTRY_QNT 1

PO_NUMBER 458987567

PO_IT 00001

MVT_IND B

hi i have the following internal table in that table i have to get the plant and stge location from ekpo table using po line item no and update this internal table with plant and storage location.

can any one please send the code for this.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this..

DATA: BEGIN OF ITAB_PO OCCURS 0,

EBELN TYPE EBELN,

EBELP TYPE EBELP,

WERKS TYPE WERKS_D,

LGORT TYPE LGORT_D,

END OF ITAB_PO.

  • GET THE PO DETAILS.

IF NOT ITAB[] IS INITIAL.

SELECT EBELN EBELP WERKS LGORT

FROM TABLE EKPO

INTO TABLE ITAB_PO

FOR ALL ENTRIES IN ITAB

WHERE EBELN = ITAB-PO_NUMBER

AND EBELP = PO_IT.

IF SY-SUBRC = 0.

SORT ITAB_PO BY EBELN EBELP.

ENDIF.

ENDIF.

DATA: V_TABIX TYPE SYTABIX.

  • PROCESS THE INTERNAL TABLE.

LOOP AT ITAB.

V_TABIX = SY-TABIX.

READ TABLE ITAB_PO

WITH KEY EBELN = ITAB-PO_NUMBER

EBELP = ITAB-PO_IT.

IF SY-SUBRC = 0.

ITAB-PLANT = ITAB_PO-WERKS.

ITAB-STGE = ITAB_PO-LGORT.

MODIFY ITAB INDEX V_TABIX

TRANSPORTING PLANT STGE.

ENDIF.

ENDLOOP.

Thanks,

Naren

4 REPLIES 4

Former Member
0 Kudos

Hi,

Try this..

DATA: BEGIN OF ITAB_PO OCCURS 0,

EBELN TYPE EBELN,

EBELP TYPE EBELP,

WERKS TYPE WERKS_D,

LGORT TYPE LGORT_D,

END OF ITAB_PO.

  • GET THE PO DETAILS.

IF NOT ITAB[] IS INITIAL.

SELECT EBELN EBELP WERKS LGORT

FROM TABLE EKPO

INTO TABLE ITAB_PO

FOR ALL ENTRIES IN ITAB

WHERE EBELN = ITAB-PO_NUMBER

AND EBELP = PO_IT.

IF SY-SUBRC = 0.

SORT ITAB_PO BY EBELN EBELP.

ENDIF.

ENDIF.

DATA: V_TABIX TYPE SYTABIX.

  • PROCESS THE INTERNAL TABLE.

LOOP AT ITAB.

V_TABIX = SY-TABIX.

READ TABLE ITAB_PO

WITH KEY EBELN = ITAB-PO_NUMBER

EBELP = ITAB-PO_IT.

IF SY-SUBRC = 0.

ITAB-PLANT = ITAB_PO-WERKS.

ITAB-STGE = ITAB_PO-LGORT.

MODIFY ITAB INDEX V_TABIX

TRANSPORTING PLANT STGE.

ENDIF.

ENDLOOP.

Thanks,

Naren

0 Kudos

thanks naren.

0 Kudos

hi naren but my internal table has some extra fields movement type, mov ind, qty and i should get the plant and storage location only using po line item.

0 Kudos

It appears that you might be trying to do a goods reciept against a PO? This is correct? You simply need to do a select against the PO line EKPO and move the plant, storage location to the the itab line.

select single werks lgort into (itab-plant, itab-STGE)
            from ekpo
                where ebeln = p_ebeln   "<-- Po Number
                  and ebelp = p_ebelp.  "<-- Po item

Regards,

Rich Heilman