Original article: http://gnolux-blog.appspot.com/2010/06/30/abap_10063003.html
After a day of debugging and tracking, I felt dizzy. I woke up at night and recorded the process.
Business Background:
The Group has company code 1000 and 2000, and the sales orders under 1000 are all generated for of the procurement applications (the status quo is that each line of the Order will generate a procurement application), of the scheduler staff, merge multiple purchase applications to create a 2000 inter-company purchase order. 2000 run the material requirements and production plan according to the purchase order.
Now we can use co46 to check the problem that occurs when a sales order is required: In theory, each sales line corresponds to a purchase order line, however, each row now maps to all rows of the corresponding purchase order. On the surface, the Association logic is incorrect. Each order line is only associated with the purchase order number and does not correspond to the purchase line.
If the corresponding background configuration is not found, we decided to track the program, find out its design logic, and try again.
Tcode: co46, go to the selection screen, fill in the necessary query conditions,/h to enter the ABAP debugging status.
........................................ ......... Here is a long combination of F8, F6, and breakpoint ....... patience, care, and eyesight ..............................
Find the read operation for ebkn and EKKN, that is, the purchase application and the Purchase Order. The logic of the two operations is similar. See the code of the purchase order.
Cm61x is a structure variable. Remember that it has loaded all the row items of the current order in the previous debugging. From here, we can see that the logic should be correct when looking for the corresponding row in the purchase order, the Order + row number keys are used to calculate the numbers respectively. In this case, it may only show some problems. Keep this idea first and continue tracking.
The final data obtained is found in the internal table shown in. It can be basically determined that the number is correct, which is a problem of displaying the data.
(A sales order starts with 00001 and a purchase order starts with 460. The corresponding relationship can be determined through the extra field)
If the field extra is used to find the lower-layer data (to construct the tree node), the problem will not occur.
Next we will look for the alv_tree-related code. I set the call and create statement breakpoints TO USE THE ALV tree code for the bapi and class methods respectively.
The final end is like code, where tree and display are created.
Locate the node to be added and call io_add_line
M, in io_build_hierarchy form,
Io_add_line will output a table with the lf_nxtrs parameter, and the data source of this table is the value of the nctps field of the previously added node (see the Data graph of the second inner table ), it is not an extra field. nctps is only a purchase order number, not a row number.
Look at the code in the loop below, and the final nctps value will be sent to lf_delnr and passed as a parameter to io_add_children form. here we can see that there should be problems in getting subnodes later, retrieve all rows of the purchase order. (Question 1)
Is the process of adding a node, through if_rsnum to find the internal table (the table data in figure 2), the value of lf_rsnum is the passed purchase order number,
The subsequent code will add all rows of the purchase order number as nodes to the nodes of the current corresponding order line. If there is a purchase order at this time, the row number filtering will not be wrong. (Question 2)
In addition, this form contains recursive calls to process deeper nodes.
We can see from the above trace that there are two problems, and the last modification is as follows:
Locate the row items of the corresponding child node before calling io_add_children and upload them to the lf_delps parameter.
Add the io_add_children form field to filter out unwanted rows based on the included row item parameters.
I finally completed the modification and met my needs. I was so happy that my eyes were bitter. :)
Reference: ABAP-standard program debugging example
SAP-crack the client's lock through debugging to modify system data
ABAP-how to better add a hard breakpoint break-point to the code