Skip to Content
0

BAPI_PRODORD_GET_DETAIL in sq02

Nov 04, 2016 at 09:28 AM

156

avatar image

Hi

Working on a query in SQ02 and have to make use of BAPI_PRODORD_GET_DETAIL

The infoset starts from table aufk and use aufk-aufnr to read components via this bapi. Syntax check is fine and generating infoset is also fine. But there is nothing output from lt_component. What can be wrong here? Thanks in advance.

Here is the codes.

data: lt_BAPI_PP_ORDER_OBJECTS like BAPI_PP_ORDER_OBJECTS.

lt_BAPI_PP_ORDER_OBJECTS-COMPONENTS = 'X'.



TYPES: BEGIN OF l_component.

INCLUDE STRUCTURE  BAPI_ORDER_COMPONENT.

TYPES: END OF l_component.


data: lt_component type l_component OCCURS 0 WITH HEADER LINE.


CALL FUNCTION 'BAPI_PRODORD_GET_DETAIL'

  EXPORTING

    NUMBER                 = aufk-aufnr

*   COLLECTIVE_ORDER       =

    ORDER_OBJECTS          = lt_BAPI_PP_ORDER_OBJECTS

* IMPORTING

*   RETURN                 =

 TABLES

*   HEADER                 =

*   POSITION               =

*   SEQUENCE               =

*   OPERATION              =

*   TRIGGER_POINT          =

   COMPONENT              = lt_COMPONENT

*   PROD_REL_TOOL          =

          .

COMPONENT = lt_COMPONENT-MATERIAL.

REQ_QUAN = lt_COMPONENT-REQ_QUAN.

WITHDRAWN_QUANTITY = lt_COMPONENT-WITHDRAWN_QUANTITY.
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Raymond Giuseppi
Nov 04, 2016 at 01:06 PM
2

From a pure ABAP point of view, this is an internal table; you have to LOOP AT it to build the output fields. And with a basic Extras/structure and code you can only add some supplementary fields not add multiple records, so I suppose you get only one record per order if Infoset based on table AUFK (or similar AFKO, etc.)

So did you read Using Programs to Retrieve Data in SAP Query online documentation more suitable for your supposed requirement.

Regards,
Raymond

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks Raymond, exactly as you mentioned it's only 1 record (the last record) is displayed even if I am using LOOP reading now. thanks for the link of external retrieving data. I would need some time to study that... meanwhile, is it possible to use a table other than AUFK/AFKO to achieve it?

data: lt_BAPI_PP_ORDER_OBJECTS like BAPI_PP_ORDER_OBJECTS.


lt_BAPI_PP_ORDER_OBJECTS-COMPONENTS = 'X'.



TYPES: BEGIN OF l_component.


INCLUDE STRUCTURE  BAPI_ORDER_COMPONENT.


TYPES: END OF l_component.



data: lt_component type l_component OCCURS 0 WITH HEADER LINE.


CALL FUNCTION 'BAPI_PRODORD_GET_DETAIL'

  EXPORTING



    NUMBER                 = aufk-aufnr



*   COLLECTIVE_ORDER       =



    ORDER_OBJECTS          = lt_BAPI_PP_ORDER_OBJECTS



* IMPORTING



*   RETURN                 =



 TABLES



*   HEADER                 =



*   POSITION               =



*   SEQUENCE               =



*   OPERATION              =



*   TRIGGER_POINT          =



   COMPONENT              = lt_COMPONENT



*   PROD_REL_TOOL          =



          .


LOOP AT lt_COMPONENT WHERE RESERVATION_NUMBER = afko-rsnum.

MOVE-CORRESPONDING lt_component to order_component.

ENDLOOP.

0

Yes as already written, navigate thru provided link for 'Using Programs to Retrieve Data'. Else build query from another table replacing AFKO with RESB as initial table.

Regards,
Raymond

0
Jelena Perfiljeva
Nov 07, 2016 at 06:50 PM
0

As Raymond already explained, it is not feasible to add more lines to the query using additional coding. This has been explained on SCN many times (there are many very good blogs on Query on SCN, make sure to search and read them).

If you want to report on the components in the production orders then you'd need to start the query from the component table (RESB) and then JOIN the higher level PO tables. But this may not be very efficient, depending on your selection criteria, data volume and other factors.

What exactly are you trying to achieve and why can't you use standard reports like COOIS?

Share
10 |10000 characters needed characters left characters exceeded