Sunday, January 18, 2004

Search helps in R3 for APO data

Some quick notes on building search helps in R3 with data from APO system. When developing in APO, sooner or later one will need to build programs that use data from both systems (APO and R3). And for selection screens we end up needing to have search helps for data fields from the remote system.

SAP has an example search exit function named F4IF_SHLP_EXIT_EXAMPLE. To speed development you can copy this function rather than start from scratch. But since the function needs other code from the function group, better to copy all the function group to the customer namespace. Quick instructions: go to SE38 and make a copy of SAPLSDHI to, for example ZSDHI; then select only the function F4IF_SHLP_EXIT_EXAMPLE to copy to this new group (for example use name ZF4IF_SHLP_EXIT_EXAMPLE). Now go to the new function and make a copy for this example (example name ZAPO_ATPCAT_SHLP). In the search help exit a lot can be done. You can make some fields mandatory, you add authorizations, filter data, etc. You can find here documentation on the search help framework.

I will use the exit select control step to get the data from the APO system. Bellow is the code that is needed in the search help exit function (ZAPO_ATPCAT_SHLP). The first function call in the code is to make a remote call to the APO system to get the data (in this example I fetch the ATP categories with descriptions. Then use the F4UT_RESULTS_MAP function to map the data from the zs_atpcat structure (just ATP cat. and description) to the internal search help structures.


DATA: lt_atpcat TYPE TABLE OF zs_atpcat WITH HEADER LINE.

IF callcontrol-step = 'SELECT'.

CALL FUNCTION 'Z_ATPGET_ATPCAT'
DESTINATION 'RFCAPO'
EXPORTING
p_spras = sy-langu
TABLES
p_atpcat = lt_atpcat
EXCEPTIONS
communication_failure = 1
system_failure = 2.

CALL FUNCTION 'F4UT_RESULTS_MAP'
EXPORTING
source_structure = 'zs_atpcat'
TABLES
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = lt_atpcat
CHANGING
shlp = shlp
callcontrol = callcontrol
EXCEPTIONS
illegal_structure = 1
OTHERS = 2.

IF sy-subrc = 0.
callcontrol-step = 'DISP'.
ELSE.
callcontrol-step = 'EXIT'.
ENDIF.
EXIT. "Don't process STEP DISP additionally in this call.
ENDIF.
EXIT.


Now just go to SE11 and create a search help with the fields ATP category and description and with ZAPO_CATATP_SHLP being the search help exit.

This development pattern is simple and effective, for example to make reports in R3 with mixed data. APO has good BAPIs with fast access to data from the LiveCache. It’s quite easy to build reports based on those BAPIs. The most annoying thing is that most data structures used in APO BAPIs are not available in R3. So, in order to use these BAPIs one needs to create these dictionary elements, which ends up being a lot of boring work. Wouldn’t it be great if SAP added the APO BAPI structures to R3. And it would make sense, it’s already done for all the R3-APO remote functions that are part of the standard code.

Labels:

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home