Skip to Content
author's profile photo Former Member
Former Member

Change Bapi Wrapper

when creating CHANGE bapi wrapper , is there any rule that should follows

Except the rule define below, is there any rule/logic define inside the function?

Import – Structure to hold the BO header data being modified

Tables – Table(s) to hold the list(s) of associated item data, which are used to replace (add/modify/delete) the item data

“RETURN” as Export or Tables parameter

i have read somewhere, that in the change bapi wrapper,i need to replace the existing rows...

my problem is when i modify the value

<b><u>0001</u> Abu 1 </b>

change to

<b><u>0001</u> Abu 2</b>

after i sync

<u>0002</u> Abu 1 <<---data is not modified and syncKey changed

i new syncKey created and i check merep_10100 the old synckey eg: 0001 rows is deleted and new syncKey 0002 is created.

Is this the change bapi wrapper logic error ?

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 23, 2007 at 03:33 AM

    The reason for the behaviour is you are changing the key fields. For that item, you have marked those fields are key fields. If the key fields are changed its a new record (same Database principle) and not a modified record..

    Regards

    Ajith

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      sorry for my ignorance

      TRACE:

      Top record read from R/3 itab; conflict detected

      R/3 is userid

      SyncKey | userid | Name | QtyOrdered

      xxxxxx1 00001 Abu 1

      xxxxxx1 00001 Abu 2

      when sync

      merep_10100

      SyncKey userid Name QtyOrdered

      xxxxxx1 00001 Abu 1 (record deleted)

      xxxxxx2 00001 Abu 1 (record added)

      se16

      userid Name QtyOrdered

      00001 Abu 1 (no changes)

      Message was edited by:

      yzme yzme

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 09:53 AM

    first let me know y u have used call transaction in u r bapi function function module ......???????

    have u released u r function module as remote functionmodule.........

    have call it as api method in to u r business object..........

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 11:48 AM

    if u r using call transaction in the function module then it wont become a bapi......

    the purpose of bapi is to post the data or change the data directly in the kernal level .........

    for bapi the data will not go through the screens...........

    reward points if helpful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 12:07 PM

    I am sending u step by step procedure to how to create a bapi, n how to make it as API [ APPLICATION PROGRAMMING INTERFACE ] method ,n how to make it visible in bapi explorer ……..……… please go through the things …………iam sending u the stuff regarding to a create bapi ( instance independent bapi ) ………. But for the change bapi u need to consider the change parameter structure………. Never ever use call transaction in bapi function modules ……. U have used call transaction in in zbapi_am_p2p ……… then the data will post through the screens …….. jst check u r mailbox

    reward points if helpful

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      you mean i shouldn't use this

      <u>ZBAPI_AM_P2P</u>

      CALL TRANSACTION 'AS02' USING bdcdata MODE 'N'

      UPDATE 'S'MESSAGES

      INTO messtab.

      i want to clarify here is

      GetList: <u>ZBAPI_AM_LIST_V1</u>

      GetDetail: <u>ZBAPI_AM_DETAILS_V1 </u>

      Modify : <u>ZEMI_AM_P2P </u>

      ZEMI_AM_P2P will call ZBAPI_AM_P2P

      In ZBAPI_AM_P2P ,it will call transaction as02

      if you see the function ZEMI_AM_P2P

      it will call insert zztable to insert system date and time

      to test if the function get called.

      but i found out the function is not invoke.

      anyone pls checkout this printscreen in doc format

      worklist printscreen in doc format

      http://www.savefile.com/files/1014947

      Bapi function

      http://www.savefile.com/files/1005882

      anyone..pls help .....................

      Message was edited by:

      yzme yzme

      Message was edited by:

      yzme yzme

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 07:07 AM

    hi,

    what u did is exactly write ....but when u work with change bapi (instance dependent bapi ) u need to use change parameters also i.e

    consider tat u have created 'BAPIEN' parameter in u r wrapper bapi ......

    u should create one for parameter like 'BAPIENX' in u r bapi functionmodule ......

    in program

    bapien-synch = 'xxxxxx1'.

    bapien-userid = '00001'.

    bapien-name = 'Abu'.

    bapien-quantord = '2'. (this is the field u r changing right)

    so enable the change parameter structure such that

    bapienx-quantord = 'x'. (by assigning x to this field).

    untill and unless u enable the change parameter structure .... u r changed field wont get updated ........

    in case creating change bapi for parameters u need create one more parameter like change parameter (x parameter) ...... wat ever the field u r changing in the data base , assign x to that change parameter field.

    rewards would be helpful.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      i think i have difficulties understand you "raam"....

      can you explain more......

      the post that i post earlier is an example to make it simple for ppl to understand .

      the real data is down here.

      <b><u>Change Bapi Wrapper</u></b>

      FUNCTION zemi_am_p2p_v1.
      *"----------------------------------------------------------------------
      *"*"Local interface:
      *"  IMPORTING
      *"     VALUE(AM_DATA) LIKE  ZASTMS STRUCTURE  ZASTMS
      *"  EXPORTING
      *"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2
      *"  TABLES
      *"      AM_DETAILS STRUCTURE  ZASTMS OPTIONAL
      *"----------------------------------------------------------------------
      
      
        DATA : v_date LIKE sy-datum,
               var1 LIKE  balm-msgv1,
               var2 LIKE  balm-msgv2.
      
        REFRESH : bdcdata, messtab.
        CLEAR : bdcdata, messtab, v_date.
      *v_msg,
      
        CONCATENATE am_data-anln1 am_data-werks am_data-stort sy-datum sy-uzeit INTO zztable-char100
        SEPARATED BY space.
        INSERT zztable.
      
        SELECT SINGLE * FROM anla WHERE anln1 = am_data-anln1
                                    AND bukrs = '1000'.
      
        SELECT SINGLE * FROM anlz WHERE anln1 = am_data-anln1
                                    AND bukrs = '1000'.
      
        SELECT SINGLE * FROM anlh WHERE anln1 = am_data-anln1
                                    AND bukrs = '1000'.
      
        CONCATENATE   anla-aktiv+6(02)  anla-aktiv+4(02) anla-aktiv(04) INTO v_date.
      
      call function 'ZBAPI_AM_P2P'
         exporting
           v_anln    = anla-anln1
           v_stort   = am_data-stort
            v_txt50   = anla-txt50
            v_anlhtxt = anlh-anlhtxt
            v_kostl   = anlz-kostl
            v_werks   = anlz-werks
            v_date    = v_date.
      *    importing
      *v_msg     = v_msg.
      
        APPEND am_data TO am_details.
      
      
      ENDFUNCTION.
      
      
      
      FUNCTION zbapi_am_p2p.
      *"----------------------------------------------------------------------
      *"*"Local interface:
      *"  IMPORTING
      *"     VALUE(V_ANLN) LIKE  ANLA-ANLN1 OPTIONAL
      *"     VALUE(V_STORT) LIKE  ANLZ-STORT OPTIONAL
      *"     VALUE(V_TXT50) LIKE  ANLA-TXT50 OPTIONAL
      *"     VALUE(V_ANLHTXT) LIKE  ANLH-ANLHTXT OPTIONAL
      *"     VALUE(V_KOSTL) LIKE  ANLZ-KOSTL OPTIONAL
      *"     VALUE(V_WERKS) LIKE  ANLZ-WERKS OPTIONAL
      *"     VALUE(V_DATE) LIKE  SY-DATUM OPTIONAL
      *"  EXPORTING
      *"     VALUE(V_MSG) TYPE  STRING
      *"----------------------------------------------------------------------
      
        DATA :  var1 LIKE  balm-msgv1,
                var2 LIKE  balm-msgv2.
      
        PERFORM open_group.
      
        PERFORM bdc_dynpro      USING 'SAPLAIST' '0100'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '=MAST'.
        PERFORM bdc_field       USING 'ANLA-ANLN1' v_anln.
        PERFORM bdc_field       USING 'ANLA-ANLN2' '0'.
        PERFORM bdc_field       USING 'ANLA-BUKRS' '1000'.
      
        PERFORM bdc_dynpro      USING 'SAPLAIST' '1000'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '=TAB02'.
        PERFORM bdc_field       USING 'ANLA-TXT50' v_txt50.
        PERFORM bdc_field       USING 'ANLH-ANLHTXT' v_anlhtxt.
        PERFORM bdc_field       USING 'ANLA-AKTIV' v_date.
      
        PERFORM bdc_dynpro      USING 'SAPLAIST' '1000'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '=BUCH'.
        PERFORM bdc_field       USING 'ANLZ-KOSTL' v_kostl.
        PERFORM bdc_field       USING 'ANLZ-WERKS' v_werks.
        PERFORM bdc_field       USING 'ANLZ-STORT' v_stort.
      
        PERFORM bdc_dynpro      USING 'SAPLAIST' '3020'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '=YES'.
      
      
        CALL TRANSACTION 'AS02' USING bdcdata MODE 'N'
                                              UPDATE 'S'
                                              MESSAGES INTO messtab.
      
        PERFORM close_group.
      
        READ TABLE messtab INDEX 1.
        MOVE messtab-msgv1 TO var1.
        MOVE messtab-msgv2 TO var2.
      
      
        CLEAR v_msg.
        CALL FUNCTION 'MESSAGE_PREPARE'
             EXPORTING
                 language               = 'E'
                  msg_id                 = messtab-msgid
                  msg_no                 = messtab-msgnr
                  msg_var1               = var1
                  msg_var2               = var2
      *         MSG_VAR3               = ' '
      *         MSG_VAR4               = ' '
            IMPORTING
                 msg_text               = v_msg
             EXCEPTIONS
                  function_not_completed = 1
                  message_not_found      = 2
                  OTHERS                 = 3.
      
      
      ENDFUNCTION.
      
      

      <b><u>GetDetails Bapi Wrapper</u></b>

      FUNCTION ZBAPI_AM_DETAILS_V1.
      *"----------------------------------------------------------------------
      *"*"Local interface:
      *"  IMPORTING
      *"     VALUE(DATA_ANLN1) LIKE  ZASTMS-ANLN1 OPTIONAL
      *"  EXPORTING
      *"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2
      *"     VALUE(AM_DATA) LIKE  ZASTMS STRUCTURE  ZASTMS
      *"  TABLES
      *"      AM_DETAILS STRUCTURE  ZASTMS OPTIONAL
      *"----------------------------------------------------------------------
      
        DATA : BEGIN OF it_return OCCURS 0,
         mandt like anla-mandt,
         bukrs LIKE anlz-bukrs,
         anln1 LIKE anlz-anln1,
         anln2 LIKE anlz-anln2,
         kostl LIKE anlz-kostl,
         werks LIKE anlz-werks,
         stort LIKE anlz-stort,
         txt50 LIKE anla-txt50,
         txa50 LIKE anla-txa50,
         END OF it_return.
      
      
      
        SELECT SINGLE * INTO CORRESPONDING FIELDS OF it_return
        FROM anla AS a INNER JOIN anlz AS b
        ON a~bukrs = b~bukrs AND
           a~anln1 = b~anln1 AND
           a~anln2 = b~anln2
        WHERE
        a~anln1 = DATA_ANLN1
      * AND   b~kostl = data-kostl
      * AND   b~anln1 = DATA_ANLN1
        AND   b~werks = '1000'
        AND   b~bukrs = '1000'
        and   b~bdatu = '99991231'.
      * AND   b~anln2 = data-anln2.
        APPEND it_return.
      
        SORT it_return BY anln1.
        DELETE ADJACENT DUPLICATES FROM it_return COMPARING ALL FIELDS.
      
        am_details[] = it_return[].
      
      ENDFUNCTION.
      

      ......................................................

      <?xml version="1.0" encoding="utf-8" ?>

      - <MeRepApplication schemaVersion="1.1" id="ZAM_03" version="03">

      <Property name="CLIENT.BUILDNUMBER" />

      <Property name="C_APPLRESOLVE" />

      <Property name="DATA_VISIBLE_SHARED">X</Property>

      <Property name="E_APPLRESOLVE" />

      <Property name="FACADE_C_CLIENT">X</Property>

      <Property name="FACADE_E_CLIENT">X</Property>

      <Property name="HOMEPAGE.INVISIBLE" />

      <Property name="INITVALUE" />

      <Property name="RUNTIME">JSP</Property>

      <Property name="TYPE">APPLICATION</Property>

      - <SyncBO id="ZAM_03" version="1" type="twoWay" allowCreate="false" allowModify="true" allowDelete="false" reqDirectSync="true" downloadOrder="1">

      - <TopStructure name="TOP">

      - <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">

      <Input type="create">false</Input>

      <Input type="modify">false</Input>

      </Field>

      - <Field name="ANLN1" type="C" length="12" decimalLength="0" signed="false" isKey="false" isIndex="false">

      <Input type="create">false</Input>

      </Field>

      - <ChildStructure name="010">

      - <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">

      <Input type="create">false</Input>

      <Input type="modify">false</Input>

      </Field>

      - <Field name="BUKRS" type="C" length="4" decimalLength="0" signed="false" isKey="false" isIndex="false">

      <Input type="create">false</Input>

      </Field>

      - <Field name="ANLN1" type="C" length="12" decimalLength="0" signed="false" isKey="false" isIndex="false">

      <Input type="create">false</Input>

      </Field>

      - <Field name="ANLN2" type="C" length="4" decimalLength="0" signed="false" isKey="false" isIndex="false">

      <Input type="create">false</Input>

      </Field>

      - <Field name="KOSTL" type="C" length="10" decimalLength="0" signed="false" isKey="false" isIndex="false">

      <Input type="create">false</Input>

      </Field>

      - <Field name="WERKS" type="C" length="4" decimalLength="0" signed="false" isKey="false" isIndex="false">

      <Input type="create">false</Input>

      </Field>

      - <Field name="STORT" type="C" length="10" decimalLength="0" signed="false" isKey="false" isIndex="false">

      <Input type="create">false</Input>

      </Field>

      </ChildStructure>

      </TopStructure>

      </SyncBO>

      </MeRepApplication>

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2007 at 07:49 AM

    hey won,

    the basic purpose of the bapi is to update the data directly into the database.......and the calltransaction is to update the data through the screens .........

    irrespective of u r function modules ........ ... u cannot use call transaction in bapi.............

    if u want call transaction then u csn directly go for bdc right????

    if u use call transaction ...... u need to fill all the mandatory fields........jst check that u have attempted to fill all the mandatory fields ...............(but it is not recommended).....

    let me know y u have created the wrapper bapi............

    would u please send me u r requirement ........????

    instead of calling the transaction ......as02.......use modify or update statements to post u r data directly to the database.......and call 'bapi_transaction_commit' ....in u r programme....

    iam little bit confused abt u r javacode..........

    reward points if helpful......

    Message was edited by:

    raam

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      you mean you dont understand this:

      this is to modify the item Field "STORT" with new values

      public void modifyRecordAmt(String syncBoName,String syncKey,String newLoc){
      		SmartSyncTransactionManager transactionManager;
      		try {
      			transactionManager=dataFacade.getSmartSyncTransactionManager();
      			transactionManager.beginTransaction();
      			
      			//start modify
      			 SyncBoDescriptor sbd=descriptorFacade.getSyncBoDescriptor(syncBoName);
      			 System.err.println("modify Record: " +syncKey);
      			 SyncBo sb=dataFacade.getSyncBo(sbd,syncKey);
      			 RowDescriptor tdes=sbd.getTopRowDescriptor();
      			 RowDescriptor trd=sbd.getRowDescriptor("010");
      			 Row[] item=getItemInstances(sb,"010");
      			 FieldDescriptor fd2=trd.getFieldDescriptor("STORT");
      			 
      			 item[0].modifyFieldValue(fd2,newLoc);  
      			 sb.modifyRow(item[0]);
      			 //end modify
      			
      			transactionManager.commit();
      		} catch (SmartSyncException e1) {
      			// TODO Auto-generated catch block
      			e1.printStackTrace();
      			System.out.println("ModifyRecord Exception:" +e1.getMessage());
      		}catch(PersistenceException e){
      			e.printStackTrace();
      			System.out.println("ModifyRecord Exception:" +e.getMessage());
      		}
      	}
      

      ......

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.