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

Can you transfert internal table fields into a different structure internal table ?

0 Likes
1,221

Hello SAP Devs,

As the title states I want to know if it is possible within abap to copy the content of an internal table into another one even if the second IT has a slightly different structure (lesser columns ) ?

The reason am asking is that I'm trying to use 'BAPI_PO_GETDETAIL' to retrieve purchase order items.

The above mentioned function expects an internal table 'it_po_items' which apparently should be of a structure 1x187 ( all columns of bapiekpo) otherwise I get a runtime error.

Doing so I can't later transfer part of the content of it_po_items (11 columns only ) into et_entityset / workarea ( not mutually convertible) .

    CALL FUNCTION 'BAPI_PO_GETDETAIL'
exporting
purchaseorder = p_ebeln
items = 'X'
TABLES
* return = lt_return
po_items = it_po_items .
       TYPES:
BEGIN of line_01,
po_number TYPE ebeln ,
po_item TYPE ebelp ,
SHORT_TEXT TYPE TXZ01 ,
MATERIAL TYPE MATNR ,
CO_CODE TYPE BUKRS ,
PLANT TYPE EWERK ,
STORE_LOC TYPE LGORT_D ,
MAT_GRP TYPE MATKL ,
TARGET_QTY TYPE KTMNG ,
NET_PRICE TYPE BPREIBAPI,
NET_VALUE TYPE NWERTBAPI ,
END OF line_01 .


DATA:
it_po_items TYPE STANDARD TABLE OF bapiekpo , " internal table declaration
wa_po_items type line_01 ,
p_ebeln type ekko-ebeln .

Hello SAP Devs,

As the title states I want to know if it is possible within abap to copy the content of an internal table into another one even if the second IT has a slightly different structure (lesser columns ) ?

The reason am asking is that I'm trying to use 'BAPI_PO_GETDETAIL' to retrieve purchase order items.

The above mentioned function expects an internal table 'it_po_items' which apparently should be of a structure 1x187 ( all columns of bapiekpo) otherwise I get a runtime error.

Doing so I can't later transfer part of the content of it_po_items (11 columns only ) into et_entityset / workarea ( not mutually convertible) .

    CALL FUNCTION 'BAPI_PO_GETDETAIL'
exporting
purchaseorder = p_ebeln
items = 'X'
TABLES
* return = lt_return
po_items = it_po_items .
       TYPES:
BEGIN of line_01,
po_number TYPE ebeln ,
po_item TYPE ebelp ,
SHORT_TEXT TYPE TXZ01 ,
MATERIAL TYPE MATNR ,
CO_CODE TYPE BUKRS ,
PLANT TYPE EWERK ,
STORE_LOC TYPE LGORT_D ,
MAT_GRP TYPE MATKL ,
TARGET_QTY TYPE KTMNG ,
NET_PRICE TYPE BPREIBAPI,
NET_VALUE TYPE NWERTBAPI ,
END OF line_01 .


DATA:
it_po_items TYPE STANDARD TABLE OF bapiekpo , " internal table declaration
wa_po_items type line_01 ,
p_ebeln type ekko-ebeln .
2 REPLIES 2
Read only

0 Likes
1,032

Move-corresponding did the truck

Read only

1,032

Hi ihebdhouibi,

You can use Component operator - CORRESPONDING, which makes it possible to define separate mapping rules statically. Refer the following link to know more about it.

CORRESPONDING