‎2017 Apr 07 9:28 PM
Hi All,
Here is my requirement. I have an internal table with Sales Order and Creation date. Now, I just need to get the item details into another internal table (from VBAP) AND I need to get the Creation date from the first internal table. I know we can get the items into second internal table and then loop through the list and query the first table to get the Creation date.
My question, is it possible to get the data into second internal table directly while querying the VBAP table with the new ABAP standards (we are on 7.50 with SP 5).
Thanks in advance,
Chandra
‎2017 Apr 07 10:54 PM
Using internal tables as data sources of joins is not yet possible in that release ...
‎2017 Apr 07 10:54 PM
Using internal tables as data sources of joins is not yet possible in that release ...
‎2017 Apr 08 3:49 AM
Just join vbak, vbap then for all entries with internal sale then get sale create date in vbak and some item data in vbap.
‎2017 Apr 12 5:46 PM
How is this helpful to OP? They already said explicitly they're aware of such option.
‎2017 Apr 11 7:26 PM
‎2017 Apr 12 5:53 PM
I'm rather curious what business scenario would require such data selection? It's not unusual to search for, say, order items created in the last X days. In this case we'd just use a date range in WHERE condition. But to search so specifically for "order A items created on X date and order B items created on Y date" in one swoop seems rather odd...
Just wondering if by chance you might be over-thinking the requirement or there is some miscommunication.
‎2017 Apr 12 9:28 PM
Is this what you are looking for?
TYPES:
BEGIN OF ty_new_tab,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
erdat TYPE erdat,
END OF ty_new_tab,
tty_new_tab TYPE STANDARD TABLE OF ty_new_tab WITH EMPTY KEY.
SELECT * FROM vbak
INTO TABLE @DATA(vbak_tab)
UP TO 20 ROWS.
SELECT * FROM vbap
FOR ALL ENTRIES IN @vbak_tab
WHERE vbeln = @vbak_tab-vbeln
INTO TABLE @DATA(vbap_tab).
DATA(new_tab) =
VALUE tty_new_tab(
FOR vbap_line IN vbap_tab
( vbeln = vbap_line-vbeln
posnr = vbap_line-posnr
matnr = vbap_line-matnr
erdat = vbak_tab[ vbeln = vbap_line-vbeln ]-erdat
)
).
cl_demo_output=>display( new_tab ).
‎2017 Apr 12 11:06 PM
Yes, this technically does a LOOP with the FOR statement, but this is a single command and a single place where the data extraction is being dealt with. This is opposed to older ABAP which would have been..
DATA:
vbak_line TYPE vbak,
new_line TYPE ty_new_tab,
new_tab TYPE tty_new_tab.
MOVE-CORRESPONDING vbap_tab TO new_tab.
LOOP AT new_tab INTO new_line.
READ TABLE vbak_tab WITH KEY vbeln = sy-subrc INTO vbak_line.
new_line-erdat = vbak_line-erdat.
MODIFY new_tab FROM new_line.
ENDLOOP.