2022 Nov 21 4:19 PM
Hello Everyone,
I have been trying to access one field in deep structure.
BAdi: /SAPSLL/CUS_ECC
Method: MODIFY_IDOC_DATA
Path: /SAPSLL/ECC_CUHD_S-->/SAPSLL/ECC_CUHD_HD_S-->/SAPSLL/ECC_CUHD_PAR_T-->/SAPSLL/ECC_CUHD_PAR_S--> CTYID.
I have written code to access the value of CTYID but I'm not able to get the value of the field due to an error. (refer to screenshot)
please guide me to receive the value of the CTYID field.
Kindly assist or if a link already exists point me to it.
Thanks in advance.
2022 Nov 21 5:17 PM
Based on what you have written:
... HD[]-PAR ...
would mean the "field PAR of the internal table", that's meaningless.
You must first access a row of an internal table, then you can access a field in this row.
e.g.
LOOP AT ... HD ASSIGNING <row>.
" do something with <row>-PAR ...
2022 Nov 21 5:39 PM
Hi Sandra,
Thank you for your response. I have tried your solution but it's not working. And also I'm not trying to access the field of the internal table. Actually, I'm trying to access the field from the structure.
I have gone with the loop in order to her the field. I'm putting my code as I haven't tested it. Do let me know if it is fine!
I'll update you once I get the test data to check the code.
CODE:
*-----Below code is to check if the Ultimate Consignee’s Country code is "CA".
FIELD-SYMBOLS: <ls_ecc_par> TYPE /sapsll/ecc_cuhd_par_s.
LOOP AT is_ecc_cuhd-hd-hd_par ASSIGNING <ls_ecc_par>.
IF <ls_ecc_par>-ctyid = 'CA'.
*------Below code is to check if the Licence Type is NLR or Non NLR.
FIELD-SYMBOLS: <ls_ecc_it> TYPE /sapsll/ecc_cuhd_it_s.
FIELD-SYMBOLS: <ls_ecc_doc> TYPE /sapsll/ecc_cuhd_doc_s.
LOOP AT is_ecc_cuhd-hd-hd_it ASSIGNING <ls_ecc_it>.
LOOP AT <ls_ecc_it>-it_doc ASSIGNING <ls_ecc_doc>.
IF <ls_ecc_doc>-papno = 'NLR'.
MESSAGE 'BAdi triggered' TYPE 'I'.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDLOOP.
2022 Nov 21 8:40 PM
Based on the syntax HD[] that you have used in your initial question, it means that HD is an internal table. You can't do that:
LOOP AT is_ecc_cuhd-hd-hd_it ASSIGNING ...
You can do:
LOOP AT is_ecc_cuhd-hd ASSIGNING ...
If HD is not an internal table, then you can't use HD[] and you need to clarify the exact types of all components at all levels of your complex structure.
2022 Nov 22 7:06 AM
It seems you've not really got the concept of deep structures understood. Try this blog. https://blogs.sap.com/2013/10/09/deeper-dive-into-deep-structure/