abapsap-erpopensql

ABAP Open SQL SELECT statement displaying all linked materials to my documents


The following is the case: I'm using the DRAD and DRAW SAP tables. I would like to receive all linked material links per documents.

I have: DRAD (only relevant columns are shown):

╔══════════╦══════════╦═══════╗
║  doknr   ║ dokob    ║ objky ║
╠══════════╬══════════╬═══════╣
║ 1        ║     MARA ║  1234 ║
║ 2        ║     MARA ║  5678 ║
║ 1        ║     MARA ║  5678 ║
║ 3        ║     DOC  ║  4444 ║
╚══════════╩══════════╩═══════╝

DRAW (only relevant columns are shown):

╔══════════╦══════════╗
║  doknr   ║    name  ║
╠══════════╬══════════╬
║ 1        ║   test1  ║
║ 2        ║   test2  ║
║ 3        ║   test3  ║
╚══════════╩══════════╝

How do I select a result like:

╔══════════╦══════════╗
║  doknr   ║    objky ║
╠══════════╬══════════╬
║ 1        ║   1234   ║
║ 1        ║   5678   ║
║ 2        ║   5678   ║
╚══════════╩══════════╝

Solution

  • If my understanding is correct, table DRAW is not necessary, you just need DRAD

    SELECT FROM drad
           FIELDS doknr, objky
           WHERE dokob = 'MARA'
           INTO TABLE @DATA(lt_drad).