Saturday, December 27, 2003

How to see the APO product view from R3

The product view transaction, /SAPAPO/RRP3, is usefull for users other than planners. For instance, people related to sales may want to have accurate view of the product stocks and requirements. As these users will seldom need to work in APO. Thus it is very unconfortable to have to login in APO just to execute the product view. In this document I present a simple way for users to see the product view without leaving the R3 environment.

First create an RFC enabled function in APO with the following code:

FUNCTION z_show_productview.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(P_MATNR) TYPE /SAPAPO/MATNR
*" VALUE(P_PLANT) TYPE WERKS_D
*" EXCEPTIONS
*" PLANT_NOT_FOUND
*" MATERIAL_NOT_FOUND
*"----------------------------------------------------------------------

DATA: l_matid TYPE /sapapo/matid,
l_locid TYPE /sapapo/locid,
l_fcode TYPE syucomm,
l_loc TYPE /sapapo/locno.

l_loc = p_plant.

CALL FUNCTION '/SAPAPO/DM_LOCNO_GET_LOCID'
EXPORTING
iv_locno = l_loc
IMPORTING
ev_locid = l_locid
EXCEPTIONS
location_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE plant_not_found.
ENDIF.

CALL FUNCTION '/SAPAPO/DM_MATERIAL_GET_MATID'
EXPORTING
iv_matnr = p_matnr
IMPORTING
ev_matid = l_matid
EXCEPTIONS
matid_not_found = 1
OTHERS = 2.

IF sy-subrc <> 0.
RAISE material_not_found.
ENDIF.

CALL FUNCTION '/SAPAPO/RRP_IOLIST_SHOW'
EXPORTING
iv_simid = '000'
iv_matid = l_matid
iv_locid = l_locid.

ENDFUNCTION.


Then create the following report in R3 that calls the remote function. You need to have a remote connection between R3 and APO (for example the CIF connection).


REPORT zshowproductview.

PARAMETERS: p_matnr TYPE matnr,
p_werks TYPE werks_d.

START-OF-SELECTION.

CALL FUNCTION 'Z_SHOW_PRODUCTVIEW'
DESTINATION 'YOUR_APO_DESTINATION'
EXPORTING
p_matnr = p_matnr
p_plant = p_werks
EXCEPTIONS
communication_failure = 1
system_failure = 2
plant_not_found = 3
material_not_found = 4.

IF sy-subrc = 1 OR sy-subrc = 2.
"RFC communication error &1 &2 &3 &4
MESSAGE ID 'TN' TYPE 'E' NUMBER '059'.
ELSEIF sy-subrc = 1 OR sy-subrc = 2.
"The material specified is not available in plant &
MESSAGE ID 'LD' TYPE 'E' NUMBER '171' WITH p_werks.
ENDIF.

ENDIF.


Now when you execute in R3 the report, the executing will go to APO and product view screen will be shown. You might want to set setup some authorization schemes to avoid giving to much permissions in APO to the R3 users.

You may also want to call "LEAVE TO TRANSACTION sy-tcode" after the remote function in order to close the APO session.

Labels: ,

0 Comments:

Post a Comment

<< Home