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: 

BAPI extention to work order aiming AUFK custom field filling

sergio_atzori
Explorer
0 Kudos

Hi to all,

I'm actually operating with BAPI

BAPI_ALM_ORDER_MAINTAIN,

among several updating using within structure BAPI already provide, I'm willing to update a custom fields spotted and visible in tabstrip Extension inside IW33 transaction,

It's a custom field rowed within an append structure in table AUFK, wich I would like to get updated througout the Extension bapi's structure,

'I found along dictionary the structure 'BAPI_TE_AUFK wich i

could use to reach my aim,

Sneaking around forum I also picked up some example

on how to feed the Extension structure to get BAPI

updating my AUFK z( field),

Real problem is I don't have in Dictionary the corresponding structure as BAPI_TE_AUFKX to gain BAPI_TE_AUFK updated....,

example:

it1_bapi_te_aufk-zzfield1 = wa_data-ebeln.

it1_bapi_te_aufk-zzfield2 = 'X'.

it1_bapi_te_aufk-zzfield1 = 'X'.

it1_bapi_te_aufk-zzfield2= 'X'.

How should I solve that?

What a should get to do in order to have the twin structure x

available and globaly the BAPI sensitive to may zfield in AUFK?

Thanks a lot in advance to any help anyone could use,

Sergio,

7 REPLIES 7

Former Member
0 Kudos

Hi sergio,

You don't need the structure BAPI_TE_AUFKX because the function does not need it. See the documentation of the function BAPI_ALM_ORDER_MAINTAIN and you will see that it does not have the parameter EXTENSION_INX. Try to send only the parameter EXTENSION_IN with BAPI_TE_AUFK structure.

If you do not see any changes in your custom fields, check your configuration. I have a similar problem before, watch this thread maybe you will find it usefull.

[Update custom fields|;

Regards,

Isaac Meléndez

0 Kudos

Hi Isaac,

Thankyou for your advice, currently I'm trying procedure as follow:

data: wa_bapi_te_aufk type bapi_te_aufk.

extension_in-STRUCTURE = 'BAPI_TE_AUFK'.

wa_bapi_te_aufk-zzona = '1'. <<< my custom field

extension_in-VALUEPART1+144(1) = wa_bapi_te_aufk-zzona.

append extension_in.

clear extension_in.

yet BAPI is not working, the field does't come updated,

I had a watch to threads you marked, may be some similar customizing is required and I have to find out which way

or it my be required some other field filled in 'BAPI_TE_AUFK',

I get to work on this, 'hope to come up with something,

Thanks a lot Isaac,

Sergio,

0 Kudos

Hi sergio,

You need to specify the Order ID. Something like this:

DATA:
  ORDER_ID        TYPE AUFNR.
  WA_BAPI_TE_AUFK TYPE BAPI_TE_AUFK.

ORDER_ID = 'SDM000000001'.          " Example

EXTENSION_IN-STRUCTURE = 'BAPI_TE_AUFK'.

WA_BAPI_TE_AUFK-ORDERID = ORDER_ID. " Order ID
WA_BAPI_TE_AUFK-ZZONA   = '1'.      " Custom field

EXTENSION_IN-VALUEPART1(12)   = WA_BAPI_TE_AUFK-ORDERID.
EXTENSION_IN-VALUEPART1+12(1) = WA_BAPI_TE_AUFK-ZZONA.

APPEND EXTENSION_IN.
CLEAR EXTENSION_IN.

And about the configuration, you must do it to make it work. Read the last post of the thread I wrote before and just change the custom field for yours (AUFK-ZZONA). Also do not forget to call the function BAPI_TRANSACTION_COMMIT after BAPI_ALM_ORDER_MAINTAIN.

Regards,

Isaac Meléndez

0 Kudos

Hi Isaac,

I'm working on it, thankyou very much for your help, I'll keep you posted,

Sergio,

0 Kudos

Hello,

we are also facing the same problem but we were able to pass the customized values in the structure "BAPI_TE_AUFK" but whenever we tried to call BAPI_ALM_ORDER_MAINTAIN we are not able to update the value in the table and also the values are not appearing in the Customized tab.

Belwo is our Code to update the customized field.Please suggest.

&----


*& Report ZBAPI_ALM_ORDER

*&

&----


*&

*&

&----


REPORT zbapi_alm_order_rev.

DATA: wa_methods TYPE bapi_alm_order_method,

itab_methods LIKE TABLE OF wa_methods.

DATA: itab_return TYPE TABLE OF bapiret2 WITH HEADER LINE,

itab_numbers TYPE TABLE OF bapi_alm_numbers WITH HEADER LINE,

object_tab type table of BAPI_ALM_ORDER_HEADERS_I with header line,

  • wa_object_tab like BAPI_ALM_ORDER_HEADERS_I with header line,

object_tab_up type table of BAPI_ALM_ORDER_HEADERS_UP with header line. .

data: z_EXTENSION_IN type table of BAPIPAREX with header line.

DATA:

ORDER_ID TYPE AUFNR,

WA_BAPI_TE_AUFK TYPE BAPI_TE_AUFK.

ORDER_ID = '73039984'. " Example

z_EXTENSION_IN-STRUCTURE = 'BAPI_TE_AUFK'.

WA_BAPI_TE_AUFK-ORDERID = ORDER_ID. " Order ID

WA_BAPI_TE_AUFK-ZZbcklog = '20251111'. " Custom field

z_EXTENSION_IN-VALUEPART1(12) = WA_BAPI_TE_AUFK-ORDERID.

z_EXTENSION_IN-VALUEPART1+12(10) = WA_BAPI_TE_AUFK-ZZbcklog.

APPEND z_exTENSION_IN.

CLEAR z_EXTENSION_IN.

wa_methods-refnumber = 1.

wa_methods-objecttype = ' '.

wa_methods-method = 'SAVE'.

wa_methods-objectkey = '73039984'.

APPEND wa_methods TO itab_methods.

object_tab-orderid = '73039984'.

***object_tab-MN_WK_CTR = ' '.

append object_tab.

***

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

TABLES

it_methods = itab_methods

IT_HEADER = object_tab

  • IT_HEADER_UP = object_tab_up

EXTENSION_IN = z_EXTENSION_IN

return = itab_return

et_numbers = itab_numbers

.

*

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

  • IMPORTING

  • RETURN =

.

IF sy-subrc = 0.

  • read table it_wmdvex into wa_wmdvex index 1.

WRITE: 'Successful'.

ENDIF.

*ELSE.

  • WRITE: / 'No data changed'.

ENDIF.

Regards,

Abhsiehk

gurmukh_a
Discoverer

Dear All.

I am replying to this old post as I found the solution for this query. All the above answers are not complete so here is the final code to update custom field using BAPI  BAPI_ALM_ORDER_MAINTAIN.

Use following steps to update custom field  lets say zzdocno.

1. Append this field in AUFK which will be reflected in structure  BAPI_TE_AUFK.

2. Use below code in report or FM:

im_aufnr type aufnr value '000012345678'. "Pass order number here

IM_BAPI_TE_AUFK TYPE  BAPI_TE_AUFK. "Pass values for custom fields and Order number

IM_BAPI_TE_AUFK-aufnr = im_aufnr.

IM_BAPI_TE_AUFK-zzdocno = '67854'.

*Constant declarations.

   CONSTANTS:

         c_refnum TYPE ifrefnum VALUE '000001',

         c_header TYPE obj_typ VALUE 'HEADER',

         c_change TYPE swo_method VALUE 'CHANGE',

         c_save TYPE swo_method VALUE 'SAVE'.

   DATA: lst_methods  TYPE bapi_alm_order_method,

         li_methods  TYPE STANDARD TABLE OF bapi_alm_order_method,

         lst_header  TYPE bapi_alm_order_headers_i,

         li_header   TYPE bapi_alm_order_header_t,

         lst_ext_in TYPE bapiparex,

         li_ext_in TYPE TABLE OF bapiparex ,

         li_return     TYPE bapirettab,

         lst_return    TYPE bapiret2.      "Bapi return structure

   CLEAR  ex_update_successul .

**Order header - order number.

     lst_header-orderid = im_aufnr.

     APPEND lst_header TO li_header.

     CLEAR lst_methods .

     lst_methods-refnumber     = c_refnum.

     lst_methods-objecttype    = c_header.

     lst_methods-method        = c_change.

     lst_methods-objectkey     = im_aufnr.

     APPEND lst_methods        TO li_methods .

     CLEAR lst_methods .

     lst_methods-refnumber     = c_refnum.

     lst_methods-objecttype    = ''.

     lst_methods-method        = c_save.

     lst_methods-objectkey     = im_aufnr.

     APPEND lst_methods        TO li_methods .

*Move "updated needed" data to extension_in table.

     lst_ext_in-structure = 'BAPI_TE_AUFK'.

     lst_ext_in-valuepart1 = im_bapi_te_aufk.

     APPEND lst_ext_in TO li_ext_in.

* call the BAPI function to maintain the Order:

     CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

       EXPORTING

         iv_mmsrv_external_maintenace = space

       TABLES

         it_methods      = li_methods

         it_header       = li_header

         extension_in    = li_ext_in

         return          = li_return.

* message handling:

     IF li_return IS NOT INITIAL.

* Check if any error message created

       READ TABLE li_return INTO lst_return

                            WITH KEY type = 'E'.

       IF sy-subrc <> 0.

* Commit after call bapi

         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

         ex_update_successul = 'X'.

       ELSE.

         CLEAR  ex_update_successul .

       ENDIF.

     ENDIF.



3. Implement BADI IBAPI_ALM_ORD_MODIFY and add following code to update ZZDOCNO:


METHOD if_ex_ibapi_alm_ord_modify~modify_input_data.

   DATA: lst_header_int       TYPE almb_caufvd,

         lst_header_int_up    TYPE ibapi_caufvd_update,

         lst_BAPI_TE_AUFK type BAPI_TE_AUFK.

lst_BAPI_TE_AUFK = extension_in-valuepart1.

* Get order header values (based on structure BAPI_TE_AUFK)

   READ TABLE ct_header_int INTO lst_header_int

     WITH KEY aufnr = lst_BAPI_TE_AUFK-aufnr.

   IF sy-subrc = 0.

*   Update order header with custom field

     lst_header_int-zzdocno = lst_BAPI_TE_AUFK-zzdocno

     MODIFY ct_header_int FROM lst_header_int INDEX sy-tabix.

   ELSE.

*   Add custom field in order header

     lst_header_int-aufnr = lst_BAPI_TE_AUFK-aufnr.

     lst_header_int-zzdocno = lst_BAPI_TE_AUFK-zzdocno

     APPEND lst_header_int TO ct_header_int.

   ENDIF.

* Set order header for update

   READ TABLE ct_header_int_up INTO lst_header_int_up

     WITH KEY aufnr = lst_BAPI_TE_AUFK-aufnr.

   IF sy-subrc = 0.

*   Set flag for document no. custom field

     lst_header_int_up-zzdocno = 'X'.  

     MODIFY ct_header_int_up FROM lst_header_int_up INDEX sy-tabix.

   ELSE.

*   Set flag for document no. custom field

     lst_header_int_up-zzdocno = 'X'

     APPEND lst_header_int_up TO ct_header_int_up.

   ENDIF.

ENDMETHOD.



Hope this will help.


Cheers,

Guru

0 Kudos

Hi ,

Is it mandatory to add Z-fields in ibapi_caufvd_update structure ??