Wednesday, July 9, 2014

SAP APO CIF Debugging


SAP APO CIF Debugging Tips

1. Stop all the CIF queues:
In General, the if your are ok to stop all the CIF queues, then use the transaction SMQR and then "Deregister" the CF* queues. It will stop all the CIF queues. This transaction (SMQR) is available in APO and ERP system. As per the requirement stop the CIF queue in required system.

2. Stop CIF queues for the specific user

Generally in the productive environment above mentioned approach will not work, as we can not stop all the CIF queues (CF*), hence we need to stop user specific queues.
A) To stop user specific inbound queues in the R/3 system, go to transaction /SAPAPO/C4 and add your   user id, with options :
Logging:    As per you requirement.
Debugging: Debugging On, Recording of t/qRFCs (NOSENDS)
recording: Default

B) To stop user specific inbound queues in the APO system, go to transaction CFC2 and add your user id, with options :
RFC Mode : Queued RFC
Logging:    As per you requirement.
Debug: R (Debugging is activated and t/qRFCs are only recorded)

Note: CFC2 transaction required transport request. If you don't have transport request in that case the CFC2 entries can be directly maintained in CIFGPARAMS table.


Once the queue is stopped, then double click on the queues and you will find debug button. Here you can start your debugging.

Also, if you want to see the data in the internal table of the queue then double click on teh queue and you can find the data in the internal table.

Monday, July 7, 2014

Useful function modules


/SAPAPO/DM_PROD_LOC_READ  - Multiple matid & locid related data
/SAPAPO/LOC_GET_LOCT -- FM to get the location text
/SAPAPO/DM_MAT_TEXT_GET - material text

Function modules related to resource:
/SAPAPO/BLRG_RESNAME_GETRESUID - From res. ID get the resource name

Function Modules SAP APO Transportation lanes
  Read the overall transportation lanes
    '/SAPAPO/TR_TR_READ'
  Read means of transport
      '/SAPAPO/TR_TRM_READ'
    "Read version-dependent means of transport
        '/SAPAPO/TR_GET_TRMV'
  Read product-specific lanes
    '/SAPAPO/TR_TRPROD_READ'
  Read version-dependent sources of supply
      '/SAPAPO/TR_GET_TRPRODV'
  Read product-specific means of transport
      '/SAPAPO/TR_TRPRODM_READ'
  Read Transport Service Providers
      '/SAPAPO/TR_TRMCARR_READ'
  Read procurement relationships
      '/SAPAPO/MMPUR_TPSRC_GET_ALL'

APO Function modules related to timestamp
/SAPAPO/TIMESTAMP_ADD - Time Stamp 1 + Duration = Time Stamp 2
/SAPAPO/DURATION_GET_SECONDS-  Determines Duration in Seconds from Duration HHHHHH:MM:SS
/SAPAPO/SECONDS_GET_DURATION - Converts Duration in Seconds to Format HHHHHH:MM:SS
/SAPAPO/TIMESTAMP_DIFFERENCE - Time Stamp 1 - Time Stamp 2 = Duration
/SAPAPO/TIMESTAMP_SUBTRACT - Time Stamp 1 - Duration = Time Stamp 2
/SAPAPO/TIMESTAMP_ZONE_TO_UTC - local timestamp to UTC
/SAPAPO/TST_UTC_TO_LOCAL - UTC to local timestamp, date, time
Also, the abap command  GET TIME STAMP FIELD could be used to get the current timestamp.

APO MRP Related FM
'/SAPAPO/RRP_LC_IO_SCHEDULE' - Function module to reschedule an order. Here only the end data should passed for an order. The start date will be calculated automatically by the FM. If the start date is having date less than the plan start date (plan start date, is calculated according to the strategy settings) then this FM module will give the error, with code 44. Hence check beforehand the how much time is required to complete the order and calculate the start date and then check start date with plan start date.




Substract the seconds from the timestamp:

CALL METHOD CL_ABAP_TSTMP=>SUBTRACTSECS
  EXPORTING
    TSTMP   = TIME_STAMP
    SECS    = L_SECONDS
  RECEIVING
    R_TSTMP = TIME_STAMP.

Sunday, July 6, 2014

SAP APO Macro workbench


SAP APO Macro workbench

Transaction : /SAPAPO/ADVM

Macro Function modules:

Macro function module can be designed in the following way!
1. Go to  Transaction  /SAPAPO/ADVM
2. Double click on the planning book / data view
3. Goto Menu -> Edit -> Edit user function
4. Now, the pop up will appear. In this pop up give the user function name.
5. Click on Continue button. Which will give you another pop up window, in which exporting, tables and changing parameters would be availalble for the function module.
6. In general, one can select plob values, selid. (However, it is all dependant on your requirement).
7. value table, f argument and f calc error, will be by default selected.
8. Now, click on the save button.
9. Now, go to transaction SE37. Create a new fucntion module with the same name and parameter values as selected in the step 6 and 7.
10. Write your custom code in the user function module and call this function module in the macro as per your requirement.

Useful function modules for macro function module:
 /SAPAPO/MSDP_GET_PLOB_VALUES - Reads Displayed Planning Objects
If you loop on the selection table (where iobjnm  INTERN_MATLO ) getting out of the above FM, then you can get the matloc id.



Macro User exit and BAdI : 

User exit macro can be implemented through  user exit enhancement APODM005.
Go to transaction SMOD and then go to Enhancement:APODM005.
Alternativly you can goto transaction SE37 and look into function module EXIT_/SAPAPO/SAPMMCP6_005
In the IF clause, check for the i_macro_name = 'Your macro name' and if the condition is true then you can process your custom code, according to business logic.


Design of SAP APO PPDS Heuristic

Dear All,

Recently I have designed SAP APO PPDS heuristic. Here, I am sharing the details of designing of a new custom heuristic .

The heuristic design steps are explained in the SAP help at below URL.
http://help.sap.com/saphelp_scm41/helpdata/en/44/c1703713bf277ee10000009b38f8cf/frameset.htm


Important Function modules:
/SAPAPO/RRP_PEGID_COMPILE_IO - Compile IO node.
/SAPAPO/OM_ORDER_CHANGE - Change the order data
/SAPAPO/DM_PEGID_GET_PEGKEY - Get the pegkey table from the pegid.
/SAPAPO/DM_PEGID_GET_MATERIAL - Get the material data.
/SAPAPO/RRP_GR_PROCESSING_TIME - Get the GR processing time
/SAPAPO/RRP_PLORD_CREATE - Create orders (of a particular ATP catagory)
/SAPAPO/RRP_FLUSH_ORDERS - Flush the orders from the global memory
/SAPAPO/OM_MESSAGES_SY_STORE - Store the log messages

Important tables reuired:
/SAPAPO/HEURFUNC - The heuristic function module should be added in this table.
/SAPAPO/HEURCUST - The custom field must be added in the structure CI_HEUR_CUST
/SAPAPO/VHEURFNC - Maintenance View for /sapapo/heurfunc


Important transaction codes required to during the heuristic design.
1. /SAPAPO/CDPSC11 - Cutomize heuristic.