BAPI/FM to search prod orders confirmations by workcenter and date?

1.1k views Asked by At

I'm trying to figure out which BAPI/FM I could use to search amounts confirmed based on search criteria of date (+time if possible) and workcenter confirmed where was confirmed...

I would be using BAPI_PRODORDCONF_GETDETAIL which contains these informations, but according to BAPI guide I can only load in the data of confirmation number+confirmation counter.

Therefore the option would be to run BAPI_PRODORDCONF_GETLIST (but I can only input the production order range or confirmation number range), then filter what includes the workcenter and date I need and from those pick up confirmation number+counter and run it through BAPI_PRODORDCONF_GETDETAIL.

  • but this procedure of getting list of everything without data being filtered on serverside is extemly timeconsuming and out of SAP Gui I have timeout error... therefore I need any BAPI/FM which I could input the workcenter where was confirmed and date, and have the data filtered already...

Any ideas how to do that?

1

There are 1 answers

0
Suncatcher On BEST ANSWER

As far as I know there is no such standard FM, so your only choice is custom development.

I would suggest you MCPK transaction were this info is exposed in a handy form, but as I see that your requirement is to receive this info externally this is not appropriate for you.

The confirmations reside in AFRU table and workcenters are in CRHD, so to find confirmed quantities by workcenter you should join these tables, or use a view u_15673 where this info is linked:

TYPES: BEGIN OF prod_orders,
            rueck TYPE afru-rueck, "confirmation number
            rmzhl TYPE afru-rmzhl," confirmation counter
            gmnga TYPE afru-gmnga, " quantity
            arbid TYPE crhd-arbpl, " workcenter
          END OF prod_orders.

DATA: orders TYPE TABLE OF prod_orders.

SELECT *
  FROM u_15673
  INTO CORRESPONDING FIELDS OF TABLE orders
WHERE isdd >= '20180101' AND isdz <= '163000'.

To pull this externally, you must create RFC-enabled FM or use RFC_READ_TABLE and fetch this view with parameters, here is the sample.

Another approach is to use RFC_ABAP_INSTALL_AND_RUN. You must create an ABAP program that uses WRITE for output the results as a standard list to screen.

Send the lines of this program to RFC_ABAP_INSTALL_AND_RUN to PROGRAM parameter and the code will be executed on the remote system and this FM will return screen results as the lines of table WRITES.

Possible sample based on MCPK tcode to send to RFC_ABAP_INSTALL_AND_RUN:

CLEAR lwa_selection.
lwa_selection-selname = 'SL_SPTAG'.
lwa_selection-sign = 'I'.
lwa_selection-option = 'BT'.
lwa_selection-low = '20180101'.
lwa_selection-high = '20201231'.
APPEND lwa_selection TO li_selection.
CLEAR lwa_selection.
lwa_selection-selname = 'SL_ARBPL'.
lwa_selection-sign = 'I'.
lwa_selection-option = 'EQ'.
lwa_selection-low = '10400001'.
APPEND lwa_selection TO li_selection.


SUBMIT rmcf0200 WITH SELECTION-TABLE li_selection
        with par_stat = abap_true
    EXPORTING LIST TO MEMORY
    AND RETURN.

DATA: xlist TYPE TABLE OF abaplist.
DATA: xtext TYPE TABLE OF char200.

CALL FUNCTION 'LIST_FROM_MEMORY'
  TABLES
    listobject = xlist.

CALL FUNCTION 'LIST_TO_TXT'
  EXPORTING
    list_index = -1
  TABLES
    listtxt    = xtext
    listobject = xlist.

IF sy-subrc = 0.
  LOOP AT xtext ASSIGNING FIELD-SYMBOL(<text>).
    WRITE <xtext>.
  ENDLOOP.
ENDIF.

However, this approach is not flexible because MCPK standard layout is a bit different than you want, and is not easy to adjust programmatically.

Because of that I recommend to stick to the RFC_READ_TABLE approach.