cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_ALM_ORDER_MAINTAIN Zfields

MariaJoãoRocha
Contributor
0 Kudos

Dear SCN,

Using BAPI BAPI_ALM_ORDER_MAINTAIN with implementation of IBAPI_ALM_ORD_MODIFY is working so far so good with only 1 Zfiled.

I've followed https://answers.sap.com/questions/9081862/reg-extension-of-bapi-bapialmordermaintain.html

steps, and also https://blogs.sap.com/2012/08/09/extending-bapi-function-module-bapialmordermaintain/.

1 - Add zfields to CI_AUFK

2 - Append zfields to IBAPI_CAUFVD_UPDATE

3 - Include new field in BADI IBAPI_ALM_ORD_MODIFY


**

Scenario: 2 Zfields: ZfieldA and ZfieldB

If I want to update only 1 of the zfields - ZfieldB what shlould be done?

  • Populate ZfieldA and ZfieldB in extension_in before call BAPI_ALM:ORDER_MAINTAIN
  • Use import/export memory parameter with structure IBAPI_CAUFVD_UPDATE, for example, to know which fields, to update
  • Other…

Thanks.

Regards,

Maria João Rocha

Accepted Solutions (0)

Answers (3)

Answers (3)

NTeunckens
Active Contributor

Hello Maria

Well, judging by the Fact that you have a Productive Logic for one Custom Field, and having to expand your Logic for Multiple Fields as mentioned above, it would make sense to me to have some form of Config (via Custom Table?) to decide in what cases which Fields need to be able to be Modified ...

That Config could be used in your BAdI-Implementation to decide on the next steps ...

Is it a matter of Chronology? Or does it relate to the actual Data or Status of an OrderID? ... All of those things could be Configured via a Z-table in my opinion. Using stuff like Buffers or Memory could prove to be Errorprone, I would not advise that ... But this is my Personal opinion ofcourse.

I don't think I can provide more Suggestions here ...

Regards

Nic T.

MariaJoãoRocha
Contributor
0 Kudos

Hellom nic.teunckens,

Thanks for your reply.

It's not a complicated logic.

As an example, imagine that you want to update Order Start Date and Order Descrition at first and then, on a different moment, you want to update basic finish date.

You populate fields header-start_date and header-short_text and set header_up-start_date = 'X' and header_up-short_text = 'X'.

Call Bapi...

For the finish date just set header-finish_date and header_up-finish_date.

Call Bapi...

The logic that I pretend for zfields is the same. Update 1 field or several fields, specifying which fields should be changed.

I think the best solution is to pass to memory the corresponding structure zextension_in_up.

Regards,

Maria João Rocha

NTeunckens
Active Contributor

Hello Maria

We don't know what your dependencies are here, so how can we judge this : when should "ZFIELDA" be updated, when "ZFIELDB"?

What are your Scenario's : When OrderCreate Update "ZFIELDA", when OrderChange Update "ZFIELDB" or something like that? When given no Context, it's hard to figure it how you want it to work ...

What I would suggest is you look into using the "EXTENSIONIN"-Table in the BAPI and pass the Structure "BAPI_TE_ALM_ORDER_MAINTAIN" to that, as it contains your Custom Include or Fields ...
Please check this in Trx."SE11" ...

This way you can :

  • Add your "CI_AUFK" to an AppendStructure (let us call it "ZAPPEND_BAPI_TE_ALM_ORDER_MAINTAIN" ) ...

  • Use BAPI "BAPI_ALM_ORDER_MAINTAIN" while passing along your Custom Fields as below :
DATA:
lt_extension_in TYPE STANDARD TABLE OF bapiparex,
ls_bapi_te_alm_order_maintain TYPE bapi_te_alm_order_maintain,
ls_extension_in TYPE bapiparex,
lv_aufnr TYPE caufvd-aufnr.

CLEAR ls_extension_in.
ls_extension_in-structure = 'BAPI_TE_ALM_ORDER_MAINTAIN'.

CLEAR ls_bapi_te_alm_order_maintain.
ls_bapi_te_alm_order_maintain-refnumber = '000001'.
ls_bapi_te_alm_order_maintain-objectkey = '%00000000001'.
ls_bapi_te_alm_order_maintain-objecttype = 'HEADER'.
ls_bapi_te_alm_order_maintain-method = 'CREATE'.
ls_bapi_te_alm_order_maintain-zzfielda = '22'. "Some Value for ZFIELDA
ls_bapi_te_alm_order_maintain-zzfieldb = '99'. "Some Value for ZFIELDB

"Fill the Extension with the data ...
ls_extension_in-valuepart1 = ls_bapi_te_alm_order_maintain(240).
*ls_extension_in-valuepart2 = ls_bapi_te_alm_order_maintain+240(240).
*ls_extension_in-valuepart3 = ls_bapi_te_alm_order_maintain+480(237).
*ls_extension_in-valuepart4 = ''.
APPEND ls_extension_in TO lt_extension_in.

"ADDITIONAL CODE (Methods, Data, etc ...)

"Execute BAPI
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_header = lt_header
it_header_up = lt_header_up
it_operation = lt_operations
it_operation_up = lt_operations_up
it_objectlist = lt_objectlist
extension_in = lt_extension_in
return = lt_return
et_numbers = lt_number.

"Check for Errors and Determine COMMIT or ROLLBACK
  • In your BAdI-Implementation of "IBAPI_ALM_ORD_MODIFY" you can Specify which Fields you want Marked for Modification, depending on your Requirements ...
DATA:
ls_bapi_te_alm_order_maintain TYPE bapi_te_alm_order_maintain,
lv_aufnr TYPE caufvd-aufnr.
FIELD-SYMBOLS:
<ls_header_int> TYPE LINE OF almb_caufvd_tab_int,
<ls_header_int_up> TYPE LINE OF almb_caufvd_up_tab_int.

IF extension_in-structure IS NOT INITIAL.
CASE extension_in-structure.
WHEN 'BAPI_TE_ALM_ORDER_MAINTAIN'.
"Only the First Valuepart was defined and holds both ZZ-Fields ...
ls_bapi_te_alm_order_maintain = extension_in+240.

"When OrderCreate, Allow Update of ZZFIELDA
IF ls_bapi_te_alm_order_maintain-objecttype = 'HEADER' AND
ls_bapi_te_alm_order_maintain-method = 'CREATE'.

lv_aufnr = ls_bapi_te_alm_order_maintain-objectkey.
LOOP AT ct_header_int ASSIGNING <ls_header_int>
WHERE aufnr = lv_aufnr.

MOVE-CORRESPONDING ls_bapi_te_alm_order_maintain TO <ls_header_int>.
READ TABLE ct_header_int_up ASSIGNING <ls_header_int_up>
INDEX sy-tabix.
"CI_AUFK-Custom Field ENABLE MODIFICATION ZZFIELDA
<ls_header_int_up>-zzfielda = abap_true.
<ls_header_int_up>-zzfieldb = abap_false.
ENDLOOP.
ENDIF.

"When OrderChange, Allow Update of ZZFIELDB
IF ls_bapi_te_alm_order_maintain-objecttype = 'HEADER' AND
ls_bapi_te_alm_order_maintain-method = 'CHANGE'.

lv_aufnr = ls_bapi_te_alm_order_maintain-objectkey.
LOOP AT ct_header_int ASSIGNING <ls_header_int>
WHERE aufnr = lv_aufnr.

MOVE-CORRESPONDING ls_bapi_te_alm_order_maintain TO <ls_header_int>.
READ TABLE ct_header_int_up ASSIGNING <ls_header_int_up>
INDEX sy-tabix.
IF sy-subrc = 0.
"CI_AUFK-Custom Field ENABLE MODIFICATION ZZFIELDB
<ls_header_int_up>-zzfielda = abap_false.
<ls_header_int_up>-zzfieldb = abap_true.
ENDIF.
ENDLOOP.
ENDIF.

WHEN OTHERS.
ENDCASE.
ENDIF.

Please consider, this is just some Sample-Code. So don't expect it to work "out-of-the-box", nor do I say that this is the perfect solution. However, I would recommend using the "BAPI_TE_ALM_ORDER_MAINTAIN" and take advantage of its Structure and possibilities to make sure you only want a Specific Update for a Specific OrderID for a Specific Method-Call ...


Hope this helps


Nic T.

MariaJoãoRocha
Contributor
0 Kudos

Hello nic.teunckens,

Thanks for yoyr reply.

I'll try to explain my problem.

First I want to say that we are using BAPI_ALM_ORDER_MANTAIN/IBAPI_ALM_ORD_MODIFY in production system with no problems. But only updates 1 Z field.

Requirement: Update several Zfields but at different times. For example when the order is created it's necessary to update ZfieldA, or ZfieldA and ZfieldB. Then, later, we need only to update ZfieldA and ZfieldC, ...

How to know which fields to update?

In fact a similar structure to IT_HEADER_UP (fields type char 1) to select the fields we want to update.

We can pass all fields but, in this case, we must select the values,to not losing values...

Or we can pass ZEXTENSION_IN_UP(new) or IBAPI_CAUFVD_UPDATE (already exists) to memory and then in IBAPI_ALM_ORD_MODIFY implementation import ...

What's the best solution?

Regards,

Maria João Rocha

former_member807770
Discoverer
0 Kudos

Hi All,

I am currently building an interface which requires me to Create Work Order & Notification(using BAPI_ALM_ORDER_MAINTAIN) with internal number range & maintain the external identifier in AUFK & QMEL table as Zfields. I have added the Z custom fields using the CI_AUFK & CI_QMEL.

I was successfully able to implement Work Order creation with Zfield following the steps mention in the above post.

Now I want to try to supply Zfields for the notification through this BAPI_ALM_ORDER_MAINTAIN (method Createtonotif). Has anyone tried this before?

MariaJoãoRocha
Contributor
0 Kudos

Hi Rajeshwari Kute,

We use, for update zfields: BAPI_ALM_NOTIF_DATA_MODIFY + BADI NOTIF_EVENT_SAVE.

Regards,