Sequence issue of address line for contact person
1. The normal format of the address line
Generally, when the contact person been selected or changed in order, the contact person’s first name &last name always been concatenated as name1 like below.
If contact details been changed it’ll create new entries at table ADR* accordingly meanwhile VBPA-ADRDA been changed from ‘D’ to ‘E’. Then usually we need to sync those new master data to external systems like SFDC etc.
2. The unusual format of the address line
One user surprised to find out the contact person’s first name and last name not always on the first line of the Name sector like below as Name3, which impacts the further processing at the external system side.
I thought this could be controlled by customer user exit like SZAD0001 (refer to this), but I find no customized logic. Actually, the contact details screen in order shares the same sequence at the print preview like VAP3 as well. So no need to check at order processing at all.
The root of this format
It depends on the field Formatting routine keys for printing addresses (T005-ADDRS). You can check the standard document for data element ADDRS_005 (or here).
Tips of format determination
The key function module is ‘ADDRESS_INTO_PRINTFORM’ and all address lines added by the method ‘ADD_PRINTFORM_lINE’ of CL_ADDR_PRINTFORM. The best point to set a breakpoint here to check when the address line been inserted especially for the 1st line.
Then will found out different sub-method been called like address_layout_001, etc. The layout number controlled by is_t005_rec-ADDRS at method address_layout.
Field is_t005_rec-ADDRS fetched by method t005 at if_addr_printform~printform from T005 table.
For my case, the contact’s customer which country is Netherland, ADDRS is 003. So the address layout will use the method ‘address_layout_003′.
Here the flag iv_person_above_organization controls whether a person’s address should be above the organization or below the organization.
The flag IV_PERSON_ABOVE_ORGANIZATION is input parameters of FM: ADDRESS_INTO_PRINTFORM and it’s blank.
Then everything became clear inside this method ‘PRINT_PERSON_BELOW_ORG’. This is why the first name and last name from the contact master became the 3rd line as Name3 at that order.
So different country has those pre-defined layouts against it, and each process method ‘method ‘address_layout_XXX’ has specific logic inside. If some formatting issue for address lines, check the country of the customer and key field T005-ADDRS first!
Maybe trace back the logic pure from debugging is workable, but along with business knowledge will make you more efficient for sure! otherwise, it’ll lead to hair loss for sure!