You have the SES number and you need to get the details of services.
Tables in question:
ESSR is the Service Entry Sheet Header Data. SES number and the PO number are available in this table.
ESLH is the Service Package Header Data. Please pay attention to the word Package Header Data. PACKNO is the primary key of this table.
ESLL is the Lines of Service Package. This is package item.
Link between these tables are established using PACKNO.
ESSR-PACKNO –> ESLH-FPACKNO (Parent package number). Check with functional consultant if field FPACKNO is to be used or HPACKNO is to be used for your system.
ESLH-PACKNO –> ESLL-PACKNO
The final data in ESLL would have one extra line for the Package Header identification. You need to remove this line in your logic to get SES item details.
Option 1. If ESLL-PACKNO = ESLL-FPACKNO .. Ignore this line.
Option 2. Other way round is to delete the ESLL entry which has ESLL-PACKAGE = ABAP_TRUE (X).
Option 3. Or delete ESLL entry which has SUB_PACKNO NOT EQUAL to blank.
Please consult your functional/business before implementing option 2 and option 3. There might be some customization in your system or multiple sub packages which needs to be handled intelligently. Option i is the safest bet..
In one of our project, we used option 1.
If you do not want to hit two database tables ESLH and ESLL, then directly fetch the data from standard database view ML_ESLL (Service Lines with Package Header Data), using ML_ESLL-PACKNO = ESSR-PACKNO.
Image source: via Free Stock Photos foter.com