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

Select statement to use existing internal table data

Former Member
0 Likes
3,420

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

1 ACCEPTED SOLUTION
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,398

Using internal tables as data sources of joins is not yet possible in that release ...

7 REPLIES 7
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,399

Using internal tables as data sources of joins is not yet possible in that release ...

Read only

Former Member
0 Likes
2,398

Just join vbak, vbap then for all entries with internal sale then get sale create date in vbak and some item data in vbap.

Read only

0 Likes
2,398

How is this helpful to OP? They already said explicitly they're aware of such option.

Read only

palash_mazumder
Participant
0 Likes
2,398

Use the inner join,,,,,,

Read only

Jelena_Perfiljeva
Active Contributor
2,398

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.

Read only

raghug
Active Contributor
0 Likes
2,398

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 ).
Read only

raghug
Active Contributor
0 Likes
2,398

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.