cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_ALM_ORDER_MAINTAIN not updating certain header fields

Former Member
0 Kudos

Hi,

I'm having a problem updating header fields through this bapi. Originally I've been updating the header, text and operation values together with only text and operation being updated. Somehow the header details do not update in the same call, even though I tried alternating the save method. However, once I separated the header and updated it on its own, I've managed to update only short text and revision. I need to update functional location and equipment as well, but these values are not going through, even though I get a success message saying the order was saved. I'm doing this through Java WebDynpro so I don't have any code to display. Does anyone have any idea why this is happening? Any help would be appreciated.

Joanna

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Joanna,

Just check if you are able to use this function module in isolation. If you are not able to update through R/3 itself, please post a question in ABAP Forum(frenetic forum), they will definitely be able to suggest something.

If you have any particular problems through Web Dynpro, please paste your Web Dynpro code(especially how you fill the structure/table) and one of us will be able to help you out.

Regards,

Subramanian V.

Former Member
0 Kudos

Hi Subramaniam,

I am not able to test the function module in isolation at the moment, but it seems to work through single test from SE37, althought I don't see the results because there's no commit.

However, I've got some of the code here that sets up the structures.

//@@begin javadoc:onActionSaveOrder(ServerEvent)

/** Declared validating event handler. */

//@@end

public void onActionSaveOrder(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionSaveOrder(ServerEvent)

wdContext.currentContextElement().setSaveButtonVisibility(WDVisibility.NONE);

//Get the editable fields with the new values

String orderId = wdContext.currentEs_HeaderElement().getOrderid();

// Set values for header details

wdContext.nodeIt_Methods().getIt_MethodsElementAt(0).setObjectkey(orderId);

wdContext.nodeIt_Methods().getIt_MethodsElementAt(0).setObjecttype("HEADER");

wdContext.nodeIt_Methods().getIt_MethodsElementAt(0).setMethod("CHANGE");

wdContext.nodeIt_Methods().getIt_MethodsElementAt(0).setRefnumber("000001");

wdContext.currentIt_HeaderElement().setOrderid(orderId);

wdContext.currentIt_HeaderElement().setShort_Text(wdContext.currentContextElement().getShortTextDescription());

wdContext.currentIt_HeaderElement().setFunct_Loc(wdContext.currentContextElement().getFuncLoc());

wdContext.currentIt_HeaderElement().setEquipment(wdContext.currentContextElement().getEquipment());

wdContext.currentIt_Header_UpElement().setOrderid(orderId);

wdContext.currentIt_Header_UpElement().setShort_Text(true);

wdContext.currentIt_Header_UpElement().setFunct_Loc(true);

wdContext.currentIt_Header_UpElement().setEquipment(true);

// Set values for long text

wdContext.nodeIt_Methods().getIt_MethodsElementAt(1).setObjectkey(orderId);

wdContext.nodeIt_Methods().getIt_MethodsElementAt(1).setObjecttype("TEXT");

wdContext.nodeIt_Methods().getIt_MethodsElementAt(1).setMethod("CHANGE");

wdContext.nodeIt_Methods().getIt_MethodsElementAt(1).setRefnumber("000001");

String longText = wdContext.currentContextElement().getLongTextDescription();

if(!longText.equals("") && longText != null)

{

saveLongText(orderId);

}

// Set values for operations

// First get the activity number from the chosen operation

String act = wdContext.currentEt_OperationsElement().getActivity();

String objKey = orderId.concat(act);

wdContext.nodeIt_Methods().getIt_MethodsElementAt(2).setObjectkey(objKey);

wdContext.nodeIt_Methods().getIt_MethodsElementAt(2).setObjecttype("OPERATION");

wdContext.nodeIt_Methods().getIt_MethodsElementAt(2).setMethod("CHANGE");

wdContext.nodeIt_Methods().getIt_MethodsElementAt(2).setRefnumber("000001");

wdContext.currentIt_OperationElement().setActivity(act);

wdContext.currentIt_OperationElement().setDescription(wdContext.currentContextElement().getOperationShortText());

wdContext.currentIt_Operation_UpElement().setActivity(true);

wdContext.currentIt_Operation_UpElement().setDescription(true);

// Set values for save element

wdContext.nodeIt_Methods().getIt_MethodsElementAt(3).setMethod("SAVE");

wdContext.nodeIt_Methods().getIt_MethodsElementAt(3).setObjectkey(orderId);

wdThis.wdGetSCAUptimeWorkOrderCustController().executeBapi_Alm_Order_Maintain();

wdThis.wdGetSCAUptimeWorkOrderCustController().executeBapi_Commit();

The result of this was my short text value was copied to the long text, but in the short text field itself was a blank. Both functional location and equipment also saved a blank even when I entered values.

The long text and operation short text seemed to save just fine, but now I'm getting the same problem when I update the operation short text and long text, as in it copies to the long text but saves a blank in short text.

Hope this makes sense.

Joanna

Former Member
0 Kudos

I would also suggest that you write an ABAP program to test your BAPI function module( so you can call both BAPI and commit) as you suggest some values do get saved properly.

I also assume that you are not receiving any NullPointer error, therefore your values are being properly populated into the tables.

Please refer to this thread as well:

Regards,

Subramanian V.

Former Member
0 Kudos

Hi Subramaniam,

I just tested the bapi from within the r/3 in my own program, and it updated the values successfully. Now I'm really stumped because to me I'm building exactly the same structures but it doesn't work from webdynpro. It could be that the functional location is not updating because it requires a conversion into an internal number (although I'm already doing that). I'm running out of ideas. Here's a copy of my abap code.

&----


*& Report Z_UPDATE_WORK_ORDER_JC *

*& *

&----


*& *

*& *

&----


report Z_UPDATE_WORK_ORDER_JC.

data: IT_METHODS like standard table of BAPI_ALM_ORDER_METHOD,

WA_METHODS like line of IT_METHODS.

data: IT_HEADER like standard table of BAPI_ALM_ORDER_HEADERS_I,

WA_HEADER like line of IT_HEADER.

data: IT_OPERATION like standard table of BAPI_ALM_ORDER_OPERATION,

WA_OPERATION like line of IT_OPERATION.

data: IT_TEXT like standard table of BAPI_ALM_TEXT,

WA_TEXT like line of IT_TEXT.

data: IT_TEXT_LINE like standard table of BAPI_ALM_TEXT_LINES,

WA_TEXT_LINE like line of IT_TEXT_LINE.

data: IT_RETURN like standard table of BAPIRET2,

WA_RETURN like line of IT_RETURN.

start-of-selection.

  • METHODS SECTION

move '1' to WA_METHODS-REFNUMBER.

move 'HEADER' to WA_METHODS-OBJECTTYPE.

move 'CHANGE' to WA_METHODS-METHOD.

move '000098000242' to WA_METHODS-OBJECTKEY.

insert WA_METHODS into table IT_METHODS.

move '1' to WA_METHODS-REFNUMBER.

move 'TEXT' to WA_METHODS-OBJECTTYPE.

move 'CHANGE' to WA_METHODS-METHOD.

move '000098000242' to WA_METHODS-OBJECTKEY.

append WA_METHODS to IT_METHODS.

move '2' to WA_METHODS-REFNUMBER.

move 'TEXT' to WA_METHODS-OBJECTTYPE.

move 'CHANGE' to WA_METHODS-METHOD.

move '0000980002420010' to WA_METHODS-OBJECTKEY.

append WA_METHODS to IT_METHODS.

move '1' to WA_METHODS-REFNUMBER.

move 'OPERATION' to WA_METHODS-OBJECTTYPE.

move 'CHANGE' to WA_METHODS-METHOD.

move '0000980002420010' to WA_METHODS-OBJECTKEY.

append WA_METHODS to IT_METHODS.

move '' to WA_METHODS-REFNUMBER.

move '' to WA_METHODS-OBJECTTYPE.

move 'SAVE' to WA_METHODS-METHOD.

move '000098000242' to WA_METHODS-OBJECTKEY.

append WA_METHODS to IT_METHODS.

  • HEADER SECTION

move '000098000242' to WA_HEADER-ORDERID.

move 'MY TEST' to WA_HEADER-MN_WK_CTR.

move '?0100000000000000016' to WA_HEADER-FUNCT_LOC.

move 'Joanna short text' to WA_HEADER-SHORT_TEXT.

insert WA_HEADER into table IT_HEADER.

  • TEXT SECTION

move '000098000242' to WA_TEXT-ORDERID.

move '1' to WA_TEXT-TEXTSTART.

move '2' to WA_TEXT-TEXTEND.

insert WA_TEXT into table IT_TEXT.

move '000098000242' to WA_TEXT-ORDERID.

move '0010' to WA_TEXT-ACTIVITY.

move '3' to WA_TEXT-TEXTSTART.

move '4' to WA_TEXT-TEXTEND.

append WA_TEXT to IT_TEXT.

  • TEXT LINES SECTION

move 'test long text' to WA_TEXT_LINE-TDLINE.

insert WA_TEXT_LINE into table IT_TEXT_LINE.

move 'test long text again' to WA_TEXT_LINE-TDLINE.

append WA_TEXT_LINE to IT_TEXT_LINE.

move 'test long text operation' to WA_TEXT_LINE-TDLINE.

append WA_TEXT_LINE to IT_TEXT_LINE.

move 'test long text operation again' to WA_TEXT_LINE-TDLINE.

append WA_TEXT_LINE to IT_TEXT_LINE.

  • OPERATION SECTION

move '10' to WA_OPERATION-ACTIVITY.

move 'SAMPLE TEXT OPERATION' to WA_OPERATION-DESCRIPTION.

insert WA_OPERATION into table IT_OPERATION.

  • Print out what's being sent in

loop at IT_METHODS into WA_METHODS.

write : / WA_METHODS-REFNUMBER,

WA_METHODS-OBJECTTYPE,

WA_METHODS-METHOD,

WA_METHODS-OBJECTKEY.

endloop.

loop at IT_HEADER into WA_HEADER.

write : / WA_HEADER-ORDERID,

WA_HEADER-MN_WK_CTR,

WA_HEADER-FUNCT_LOC,

WA_HEADER-SHORT_TEXT.

endloop.

loop at IT_TEXT into WA_TEXT.

write : / WA_TEXT-ORDERID,

WA_TEXT-TEXTSTART,

WA_TEXT-TEXTEND.

endloop.

loop at IT_TEXT_LINE into WA_TEXT_LINE.

write : / WA_TEXT_LINE-TDLINE.

endloop.

loop at IT_OPERATION into WA_OPERATION.

write : / WA_OPERATION-ACTIVITY,

WA_OPERATION-DESCRIPTION.

endloop.

call function 'BAPI_ALM_ORDER_MAINTAIN'

tables

IT_METHODS = IT_METHODS

IT_HEADER = IT_HEADER

  • IT_HEADER_UP =

  • IT_HEADER_SRV =

  • IT_HEADER_SRV_UP =

  • IT_USERSTATUS =

  • IT_PARTNER =

  • IT_PARTNER_UP =

IT_OPERATION = IT_OPERATION

  • IT_OPERATION_UP =

  • IT_RELATION =

  • IT_RELATION_UP =

  • IT_COMPONENT =

  • IT_COMPONENT_UP =

IT_TEXT = IT_TEXT

IT_TEXT_LINES = IT_TEXT_LINE

  • EXTENSION_IN =

RETURN = IT_RETURN

*et_numbers = et_numbers

.

call function 'BAPI_TRANSACTION_COMMIT'.

loop at IT_RETURN into WA_RETURN.

write : / WA_RETURN-TYPE,

WA_RETURN-MESSAGE.

endloop.

I hope someone has some idea. Thanks.

Joanna

Former Member
0 Kudos

Please paste your Web Dynpro code, where you have created the elements for methods,header,operation and text_line.

Most likely there will be a createHeaderElement, createMethodElement etc...

Secondly, you may also send me the zip file to my email id -

Subramanian[dot]Venkateswaran[at]gmail[dot]com

Regards,

Subramanian V.

Former Member
0 Kudos

Hi Subramaniam,

Here's a copy of the code that instantiates the methods, header and text tables.

Bapi_Alm_Order_Maintain_Input maintainInput = new Bapi_Alm_Order_Maintain_Input();

wdContext.nodeBapi_Alm_Order_Maintain_Input().bind(maintainInput);

Bapi_Alm_Order_Headers_I inputHeader = new Bapi_Alm_Order_Headers_I();

maintainInput.addIt_Header(inputHeader);

Bapi_Alm_Order_Headers_Up headerUp = new Bapi_Alm_Order_Headers_Up();

maintainInput.addIt_Header_Up(headerUp);

Bapi_Alm_Order_Operation operation = new Bapi_Alm_Order_Operation();

maintainInput.addIt_Operation(operation);

Bapi_Alm_Order_Operation_Up operationUp = new Bapi_Alm_Order_Operation_Up();

maintainInput.addIt_Operation_Up(operationUp);

Bapi_Alm_Text text = new Bapi_Alm_Text();

maintainInput.addIt_Text(text);

Bapi_Alm_Text_Lines textLine = new Bapi_Alm_Text_Lines();

maintainInput.addIt_Text_Lines(textLine);

Bapi_Alm_Order_Method changeMethod = new Bapi_Alm_Order_Method();

//changeMethod.setRefnumber("000001");

//changeMethod.setObjecttype("HEADER");

maintainInput.addIt_Methods(changeMethod);

/*

Bapi_Alm_Order_Method changeTextMethod = new Bapi_Alm_Order_Method();

//changeTextMethod.setObjecttype("TEXT");

//changeTextMethod.setRefnumber("000001");

maintainInput.addIt_Methods(changeTextMethod);

Bapi_Alm_Order_Method saveTextMethod = new Bapi_Alm_Order_Method();

//saveTextMethod.setMethod("SAVE");

maintainInput.addIt_Methods(saveTextMethod);

Bapiret2 changeReturn = new Bapiret2();

maintainInput.addReturn(changeReturn);

I do this in the init method of the custom controller and just fill in the values in the maintain view after reading in the user values. Hope this helps. Thanks.

Joanna

Former Member
0 Kudos

I've solved it! It had to do with me using update tables. I removed them and the values now update.

Joanna