on 2007 Aug 23 3:52 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i am not changing the key field,
syncKey Name QtyOrdered
xxxxxxx1 Abu 1
changed to
xxxxxxx1 Abu 2
merep_10100
xxxxx1 Abu 1 (deleted)
xxxxx2 Abu 1 (added , no value change)
in client application
syncKey Name QtyOrdered
xxxxxxx2 Abu 1
2) Is there any rule/logic inside the change bapi wrapper function except the import , export, table param
Message was edited by:
yzme yzme
It might be some coding issues of the bapi wrapper..
Go to the backend and test the bapi wrappers.
1. Run Modify bapi wrapper with the changes (say Abu 2)
2. Run GetDetail
See the results from GetDetail... Check whether its returning Abu 1 or Abu 2.
Also what is the R/3 key field here. Is it Abu??
Regards
Ajith
R/3 KEY FIELD is
xxxxxxx1 meaning 0001298831
xxxxxxx2 0001298832
after i check the function(SE37) modify and getdetail, it works as expected
when i modify the value (SE37) and check with getdetail , it is changed.
but no in client.
public void modifyRecordAmt(String syncBoName,String syncKey){
SyncBoDescriptor sbd=descriptorFacade.getSyncBoDescriptor(syncBoName);
try {
System.err.println("modify Record: " +syncKey);
SyncBo sb=dataFacade.getSyncBo(sbd,syncKey);
RowDescriptor tdes=sbd.getTopRowDescriptor();
Row trow=sb.getTopRow();
FieldDescriptor fd1=tdes.getFieldDescriptor("STORT");
trow.modifyFieldValue(fd1,"3");
RowDescriptor trd=sbd.getRowDescriptor("010");
Row[] item=getItemInstances(sb,"010");
FieldDescriptor fd2=trd.getFieldDescriptor("STORT");
item[0].modifyFieldValue(fd2,"3");
sb.modifyRow(trow);
sb.modifyRow(item[0]);
} catch (PersistenceException e) {
// TODO Auto-generated catch block
System.out.println("Exception :" +e.getMessage());
e.printStackTrace();
}catch(Exception e){
System.out.println("Exception: " +e.getMessage());
}
}
As I told earlier, your R/3 key field is changing. Incase of modify, you are not supposed to change the key field. use the same key and update the changed fields.
If before update is
xxxxxxx1 Abu 1
thn after update it should be like
xxxxxxx1 Abu 2
if xxxxxxx1 is the R/3 key (field marked as key filed in merep_sbuilder)
Regards
Ajith
As I told earlier, your R/3 key field is changing.
In response to this,
i am not changing my keyfield, i just modify the QtyOrdered from 1 to 2.
but antonishingly , the backend will delete off the record with the syncKey (xxxxx1)
and add another record with syncKey (xxxxxx2)
The data is not modified.
I think you got confused with synckey and R/3 key..
Synckey is only in MI server and its not visible in Backend..
R/3 key field is the field (or combination of fields) which is used to identify the record in backend.. Examples of R/3 key order_id , user_id etc...
If xxxxxxxx1 is synckey, what is the R/3 key field? please explain your syncbo defeniton or upload the screen shot of sbuilder
Regards
Ajith
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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());
}
}
......
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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..........
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1/2 )
RFC-Enabled
<u>SyncBo ZAM_03</u>
ZBAPI_AM_LIST
ZBAPI_AM_DETAILS
ZEMI_AM_P2P ---(CHANGE)
3) what do you mean by call api into the object ?
pls refer to my mapping
http://i192.photobucket.com/albums/z231/yzme/r1.gif
http://i192.photobucket.com/albums/z231/yzme/r2.gif
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.