Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_INTERNALORDER_CREATE

Former Member
0 Likes
3,670

Hi,

I need to create internal orders, but field COAS-ASTKZ must be filled with an 'X'.

I don´t find this field, or a similar one, in import parameters or talbes of BAPI_INTERNALORDER_CREATE.

Can any one help me?

thanks in advance!

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,927

Hello Pedro

It seems that you have to use the <b>EXTENSIONIN</b> parameter. Within the BAPI you will find the following coding after creating the order:

*--------------- handle customer extension CI_AUFK --------------------
* move fields from Extension to COAS
  PERFORM map_user_fields TABLES extensionin
                          CHANGING coas.  " contains new order

And here is the coding of the FORM routine (NOTE: coding from ECC 5.0):

*&---------------------------------------------------------------------*
*&      Form  MAP_USER_FIELDS
*&---------------------------------------------------------------------*
*      -->PT_EXTENSIONIN
*      <--PS_COAS  including CI_AUFK
*----------------------------------------------------------------------*
FORM map_user_fields TABLES   pt_extensionin STRUCTURE bapiparex
                     CHANGING ps_coas STRUCTURE coas.

  DATA: ld_strlen TYPE i,
        ld_lines TYPE i,
        ls_bapi_te_aufk LIKE bapi_te_aufk.

* any table entries imported?
  READ TABLE pt_extensionin INDEX 1.
  CHECK sy-subrc = 0.

* only one table entry allowed
  DESCRIBE TABLE pt_extensionin LINES ld_lines.
  IF ld_lines > 1.
    EXIT.
  ENDIF.

* map data
  LOOP AT pt_extensionin.
    CASE pt_extensionin-structure.
      WHEN 'BAPI_TE_AUFK'.
*       map extension to coas fields
* >> UNICODE
*        DESCRIBE FIELD pt_extensionin-structure LENGTH ld_strlen.
        DESCRIBE FIELD pt_extensionin-structure
                       LENGTH ld_strlen IN CHARACTER MODE.
* << UNICODE
        MOVE pt_extensionin+ld_strlen TO ls_bapi_te_aufk.
        CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.

<b> MOVE-CORRESPONDING ls_bapi_te_aufk TO ps_coas.</b>

        ENDCATCH.
      WHEN OTHERS.
*       ignore others and do nothing
    ENDCASE.
  ENDLOOP.

ENDFORM.                               " MAP_USER_FIELDS

Structure BAPI_TE_AUFK has the following structure:

ORDERID	(type AUFNR)
.INCLUDE	CI_AUFK

Thus, you have to create <b>CI-include CI_AUFK</b> and add the required field ASTKZ.

Since I am not that experienced with CI-includes please talk to an FI-consultant whether there may be any side-effects when creating the CI-include (check the where-used-list).

Regards

Uwe

5 REPLIES 5
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,928

Hello Pedro

It seems that you have to use the <b>EXTENSIONIN</b> parameter. Within the BAPI you will find the following coding after creating the order:

*--------------- handle customer extension CI_AUFK --------------------
* move fields from Extension to COAS
  PERFORM map_user_fields TABLES extensionin
                          CHANGING coas.  " contains new order

And here is the coding of the FORM routine (NOTE: coding from ECC 5.0):

*&---------------------------------------------------------------------*
*&      Form  MAP_USER_FIELDS
*&---------------------------------------------------------------------*
*      -->PT_EXTENSIONIN
*      <--PS_COAS  including CI_AUFK
*----------------------------------------------------------------------*
FORM map_user_fields TABLES   pt_extensionin STRUCTURE bapiparex
                     CHANGING ps_coas STRUCTURE coas.

  DATA: ld_strlen TYPE i,
        ld_lines TYPE i,
        ls_bapi_te_aufk LIKE bapi_te_aufk.

* any table entries imported?
  READ TABLE pt_extensionin INDEX 1.
  CHECK sy-subrc = 0.

* only one table entry allowed
  DESCRIBE TABLE pt_extensionin LINES ld_lines.
  IF ld_lines > 1.
    EXIT.
  ENDIF.

* map data
  LOOP AT pt_extensionin.
    CASE pt_extensionin-structure.
      WHEN 'BAPI_TE_AUFK'.
*       map extension to coas fields
* >> UNICODE
*        DESCRIBE FIELD pt_extensionin-structure LENGTH ld_strlen.
        DESCRIBE FIELD pt_extensionin-structure
                       LENGTH ld_strlen IN CHARACTER MODE.
* << UNICODE
        MOVE pt_extensionin+ld_strlen TO ls_bapi_te_aufk.
        CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.

<b> MOVE-CORRESPONDING ls_bapi_te_aufk TO ps_coas.</b>

        ENDCATCH.
      WHEN OTHERS.
*       ignore others and do nothing
    ENDCASE.
  ENDLOOP.

ENDFORM.                               " MAP_USER_FIELDS

Structure BAPI_TE_AUFK has the following structure:

ORDERID	(type AUFNR)
.INCLUDE	CI_AUFK

Thus, you have to create <b>CI-include CI_AUFK</b> and add the required field ASTKZ.

Since I am not that experienced with CI-includes please talk to an FI-consultant whether there may be any side-effects when creating the CI-include (check the where-used-list).

Regards

Uwe

Read only

Former Member
0 Likes
1,927

Thanks for your answer, but I'm not trying to add a new field to the order.

ASTKZ is a standart field from AUFK I were O want to input value "X" with this BAPI.

description of field EXTENSIONIN is to use n user defined fields in table AUFK.

PA

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,927

Hello Pedro

Have you tried to use <b>BAPI_INTERNALORDER_SAVEREPLICA</b> instead of BAPI_INTERNALORDER_CREATE? The IMPORTING parameter <b>MASTERDATA </b>contains field <b>STATISTICAL</b> which likely corresponds to COAS-ASTKZ.

Regards

Uwe

Read only

0 Likes
1,927

If the cctr_posted IS not INITIAL, it default to 'X'.

in the BAPI_INTERNALORDER_CREATE

line 107

IF ( NOT i_master_data-cctr_posted IS INITIAL ).

orext-astkz = 'X'.

ENDIF.

rg

j

Read only

Former Member
0 Likes
1,927

Hi Pedro,

there is a way you can do it. you copy BAPI_INTERNALORDER_CREATE to ZXX_BAPI_INTERNALORDER_CREATE,(you can copy function group completely)

then copy import parameter:bapi2075_7 to zxx_bapi2075_7.

In structure zxx_bapi2075_7 , you add a new field: ASTKZ-&#26377;&#20851;&#32479;&#35745;&#35746;&#21333;&#26631;&#24535;.

in ZXX_BAPI_INTERNALORDER_CREATE program . line 142. (before 'call function 'KAUF_ORDER_STORE' ' ) add following code:

  • store user fields in buffer

    • begin of 'add by huang huibin

coas-astkz = i_master_data-astkz.

    • end of 'add by huang huibin