Application Development 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: 

Using EXTENSIONIN in Bapi SALESORDER_CREATFROMDAT2

Former Member
0 Kudos

Hello all....

Need someone to throw some light on how to use the EXTENSION IN Table in this BAPI. We have a structure appended to VBAP at this client and will be using this bapi to create Sales orders. I would like to post the relevant info into the fields appended in VBAP. I read through the documentation provided in the BAPI and here are a couple of things that don't seem clear....

it says "define these customer structures in the structures VBAPKOZ, VBAPKOZX, BAPE_VBAP & BAPE_VBAPX. Should the name of the structure appended matter ?

Adjust the Above structures for customer enhancements to table VBAP. How do we do this ? Any Idea ?

cheers

Prashant

8 REPLIES 8

Former Member
0 Kudos

Hi Prashant,

You should append the same fields (as are in VBAP ) to BAPE_VBAP. While appending the fields to BAPE_VBAPX the name should be same but type should be flag. I guess they woyld have already extended VBAPKOZ to match with VBAP.

SE11, enter BAPE_VBAP. menu GOTO, Append Struture.

This way you can adjust BAPE_VBAP.If you debug this BAPI a bit you will get better understanding of how this extension is used and how values should be passed.

Thanks,

Anuranjan

0 Kudos

Anuranjan,

Thanks for the prompt Reply. Yes, I did append the same fields to BAPE_VBAP that are in the append structure of VBAP. And appended the checkbox structure which are used for flagging... in the BAPE_VBAPX. I also had to do it similarly for VBAPKOZ and VBAPKOZX. However, the documentation for the BAPI (5th point) says we need to then adjust VBAP after doing the above.. Hence my doubt as in how do we adjust VBAP ?

cheers

Prashant

0 Kudos

after appending the structure , you just go to the table

choose menu Utilities - >Database Utility ->Activate and adjust.

thanks

vijay

0 Kudos

thanks ........ wanted to confirm that ..

thanks everyone for their 2 cents ..

cheers

Prashant

0 Kudos

Hi Prasanth,

You can fill the extension segment like the following code.. here i populated some z fields into header extension segment..It would help you to populate Extension segments...


FORM FILL_BAPI_HEAD_EXTN TABLES   P_BAPI_EXTN STRUCTURE BAPIPAREX
                         USING    P_SALESDOCUMENT
                                  P_ORDER_HEADER_IN
                                  STRUCTURE ZVECLMORDHEAD.

  CLEAR: R_BAPE_VBAK,
         R_BAPE_VBAKX.

*--  Append Reference to external source of claim
  MOVE:   P_ORDER_HEADER_IN-ZZEXTSRCECLM   TO  R_BAPE_VBAK-ZZEXTSRCECLM
.
  IF P_ORDER_HEADER_IN-AUGRU = K_205.
*-- Append Installation Year
    MOVE: P_ORDER_HEADER_IN-ZVINSTYR       TO  R_BAPE_VBAK-ZVINSTYR,
*-- Append Installation Month
          P_ORDER_HEADER_IN-ZVINSTMO       TO  R_BAPE_VBAK-ZVINSTMO,
*-- Append Reported Year
          P_ORDER_HEADER_IN-ZVRPTONYR      TO  R_BAPE_VBAK-ZVRPTONYR,
*-- Append Reported Month
          P_ORDER_HEADER_IN-ZVRPTONMO      TO  R_BAPE_VBAK-ZVRPTONMO.
  ENDIF.

  MOVE: 'BAPE_VBAK'                TO  P_BAPI_EXTN-STRUCTURE,
         R_BAPE_VBAK               TO  P_BAPI_EXTN+30.

  APPEND P_BAPI_EXTN.
  CLEAR: P_BAPI_EXTN,
         R_BAPE_VBAK.

  MOVE:    K_X                       TO  R_BAPE_VBAKX-ZZEXTSRCECLM.

  IF P_ORDER_HEADER_IN-AUGRU = K_205.
    MOVE:  K_X                       TO  R_BAPE_VBAKX-ZVINSTYR,
           K_X                       TO  R_BAPE_VBAKX-ZVINSTMO,
           K_X                       TO  R_BAPE_VBAKX-ZVRPTONYR,
           K_X                       TO  R_BAPE_VBAKX-ZVRPTONMO.
  ENDIF.
  MOVE:  'BAPE_VBAKX'                TO  P_BAPI_EXTN-STRUCTURE,
         R_BAPE_VBAKX                TO  P_BAPI_EXTN+30.

  APPEND P_BAPI_EXTN.
  CLEAR: P_BAPI_EXTN,
         R_BAPE_VBAKX.

ENDFORM.                    " FILL_BAPI_HEAD_EXTN

Thanks,

Sreekanth G

former_member188685
Active Contributor
0 Kudos

Hi,

there is table parameter <b>EXTENSIONIN</b>.

you need to fill that table with appropriate value.

thanks

vijay

0 Kudos

you need to do some thing like this..

IF ZZPRCQTE <> SPACE.
    MOVE HDRREC-SALES_ORDER TO VBAK-DATA-VBELN.
    MOVE ZZPRCQTE TO VBAK-DATA-ZZPRCQTE.
    VBAK-DATA-STRUCTURE = 'BAPE_VBAK'.
    APPEND VBAK-DATA TO ADD-DATA.
    CLEAR VBAK-DATA.
  ENDIF.

  CLEAR ZZPRCQTE.

 IF IDCREC-DEFECT_CODE <> SPACE.
    MOVE HDRREC-SALES_ORDER TO VBAP-DATA-VBELN.
    MOVE IHD-ITEM TO VBAP-DATA-POSNR.
    MOVE IDCREC-DEFECT_CODE TO VBAP-DATA-ZZDEFECTCD.
    VBAP-DATA-STRUCTURE = 'BAPE_VBAP'.
    APPEND VBAP-DATA TO ADD-DATA.
    CLEAR VBAP-DATA.
  ENDIF.
  MOVE TRUE TO PROCESSED_RECORD.

  CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
       EXPORTING
            SALESDOCUMENT       = SALESDOCUMENT
            ORDER_HEADER_IN     = BAPISDHD1
            logic_switch        = logic_switch
            TESTRUN             = TESTRUN
            CONVERT_PARVW_AUART = 'X'
       IMPORTING
            SALESDOCUMENT_EX    = SALESDOC-EX
       TABLES
            RETURN              = BAPIRETURN
            ORDER_ITEMS_IN      = BAPISDITM
            ORDER_PARTNERS      = BAPIPARNR
            ORDER_SCHEDULES_IN  = BAPISCHDL
            ORDER_CONDITIONS_IN = BAPICOND
            ORDER_TEXT          = BAPISDTEXT
            EXTENSIONIN         = ADD-DATA
            PARTNERADDRESSES    = BAPIADDR1.

check it the above one helps..

vijay

Former Member
0 Kudos

Hi

- Create a structure Append to add your Z-fields into VBAP. It's better to create own structure and insert it into append structure of VBAP.

- Add this structure (with the new fields) to structure VBAPKOZ;

- Create the structure-x and insert in VBAPKOZX, this enhanchement is to indicate which fields have to be changed.

So

- you'll create ZVBAP where there FIELD1, FIELD2...;

- Append ZVBAP to VBAP table and VBAPKOZ structure;

- you'll create ZVBAPX with FIELD1, FIELD2... here all fields have to be type CHAR1;

- Append ZVBAPX to VBAPKOZX structure.

Max