abap

ABAP SQL method


I need to implement a method that will output a list of available cards. The list of available cards is defined by the table ZTLO_ID_PASS-ZZPASS_ID, for ZTLO_ID_PASS-VSTEL= ZSLO_VEHICLE_LIST_SS-VSTEL

Exclude from this list those passes that have already been issued and not yet delivered. We are looking for all transportation in status 2 and 6, which do not have the status "Checkpoint exit", but at the same time there is a record with the ID of the issued pass. VTTK-TKNUM for:

LV_VSTEL= ZSLO_VEHICLE_LIST_ALV-VSTEL Let's add more VSTEL to the factory BE encoding if an entry is found: LV_VSTEL = ZTSD_WERKPRD - VSTEL_P where ZTSD_WERKPRD -VSTEL= ZSLO_VEHICLE_LIST_ALV-VSTEL

VTTS-VSTEL= LV_VSTEL VTTK-STTRG = '2' OR '6' zif_vehicle_model_dao=>mc_s_sttrg-_6 OR zif_vehicle_model_dao=>mc_s_sttrg-_2 VTTK- SHTYP='ZTRR' VTTK- DAREG= range from system date -1day to system date

I wrote a two selects for this:

This for recieving list of avaliabe cards

SELECT zzpass_id
FROM ztlo_id_pass INTO TABLE @lt_pass
WHERE vstel = @lv_vstel

And this for given or stayed:

SELECT tknum
FROM vttk
INTO TABLE @lt_tknum
WHERE sttrg IN ('2', '6')
AND shtyp = 'ZTRR'
ABD dareg = sy-datum

But I don't understand how to add the remaining selection criteria to the second SELECT, such as this one VTTS-VSTEL= LV_VSTEL and this one LV_VSTEL = ZTSD_WERKPRD - VSTEL_P where ZTSD_WERKPRD -VSTEL= ZSLO_VEHICLE_LIST_ALV-VSTEL.

Thank you for your answers!


Solution

  • LV_VSTEL= ZSLO_VEHICLE_LIST_ALV-VSTEL Let's add more VSTEL to the factory BE encoding if an entry is found: LV_VSTEL = ZTSD_WERKPRD - VSTEL_P where ZTSD_WERKPRD -VSTEL= ZSLO_VEHICLE_LIST_ALV-VSTEL

    VTTS-VSTEL= LV_VSTEL VTTK-STTRG = '2' OR '6' zif_vehicle_model_dao=>mc_s_sttrg-_6 OR zif_vehicle_model_dao=>mc_s_sttrg-_2 VTTK- SHTYP='ZTRR' VTTK- DAREG= range from system date -1day to system date

    It isnt easy to understand the requirement.
    But a join from SAP Shipment Header VTTK and Shipment Stages VTTS with your custom Z tables should be possible.

    Start with something like this:

    SELECT vttk~tknum
      FROM vttk
      JOIN vtts ON vtts~tknum = vttk~tknum
      JOIN ztsd_werkprd ON ???
          and ztsd_werkprd~vstel = zslo_vehicle_list_alv~vstel
      INTO TABLE @lt_tknum
     WHERE vttk~sttrg IN ('2', '6')
       AND vttk~shtyp = 'ZTRR'
       AND vttk~dareg BETWEEN sy-datum - 1 AND sy-datum
       AND lv_vstel = ztsd_werkprd~vstel_p.
    

    I would suggest a clear understanding of requirement aligned the data model is the best place to start.

    The sap tables VTTK ands VTTS are joined by TKNUM. How your Z tables should be joined only you can know.