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: 

Upload Order Operation's component long text

former_member212705
Active Participant

Hello experts,

I am using BAPI_ALM_ORDER_MAINTAIN to create PM order. In this BAPI i am able to upload long text at operation level but i am not able to upload long text at component level.

As long text IT_TEXT table contains only field 'Activity Number' that is operation.

In the table method i am using :

In the long text structure

I am very much confused how to upload component level long text.

I have searched a lot but could not find.

IF anyone has faced this issue kindly help me.

Thanks,

Ashish T.

1 ACCEPTED SOLUTION

former_member212854
Participant

Do you still need help, I just resolved this issue today.

17 REPLIES 17

SimoneMilesi
Active Contributor
0 Kudos

Looking at BAPI's documentation it seems to me you are missing a table


  • Texts

Texts are composed of two tables. The first table (IT_TEXT) is made up of the header data of the text. Here you must specify the object and the first and last line of the text table (both inclusive, counting from 1). This specifies a line segment in the text line table (IT_TEXT_LINES).

IT_TEXT_LINES is filled?

0 Kudos

Hello simone,

yes i have filled that table.

I am able to upload operation text but i am not able to process component level text.

0 Kudos

I am not sure whether i can update component level text with this BAPI.

PeterJonker
Active Contributor
0 Kudos

If I check the documentation in transaction BAPI it states:

  • Long text for order header, operations, and components

So it must be possible.

You also say that you only have activity which is operation.

If I look in the ItComponent parameter table then it looks to me that the key for component is RESERV_NO and RES_ITEM. These fields are also in the IT_TEXT table. Should you use them to add a text for a component ?

0 Kudos

I believe it is reservation number, but let me chk , just give me 5 mins.

0 Kudos

I checked, most probably it is reservation number from RESB table. BAPI is not working if i give reservation number as 00000001 and item 0010.

0 Kudos

OK it was a guess anyway, I was making my conclusions based on the documentation and not on experience with this BAPI.

0 Kudos

That is ok Peter. Thanks for your reply.

former_member212705
Active Participant
0 Kudos

Can anyone help

former_member212854
Participant

Do you still need help, I just resolved this issue today.

0 Kudos

Why don't you just post how you solved it? It may help someone else who comes along

0 Kudos

Ok Jurgen,

I was struggling with this issue for about half a day and finally BAPI documentation put me in right direction.

We cannot create the long text for the components before the components are actually created.

So, once the components are created, RSNUM and RSPOS  fields are populated in RESB table for the workorder (AUFNR).

It means, again we have to call the BAPI to create the long text using the RSNUM and RSPOS from tanle RESB for the Workorder(aufnr).


IT_TEXT structure does have fields RSNUM and RSPOS.


If you are still struggling, I can post the pseudo code.

Thanks,

Ashwin.

0 Kudos

Hi Ashwin,

Thanks for reply.

If you put psuedo code that will help me a lot.

0 Kudos

TYPES : BEGIN OF ty_msg,

  aufnr TYPE aufnr,

  message TYPE string,

  END OF ty_msg.

TYPES: tt_msg TYPE STANDARD TABLE OF ty_msg.

DATA : it_msg_log TYPE tt_msg,

  wa_msg_log TYPE ty_msg.

DATA : i_methods TYPE TABLE OF bapi_alm_order_method,

  i_header TYPE TABLE OF bapi_alm_order_headers_i,

  i_headerup TYPE TABLE OF bapi_alm_order_headers_up,

  i_component TYPE TABLE OF bapi_alm_order_component,

  i_componentup TYPE TABLE OF bapi_alm_order_component_up,

  i_return TYPE TABLE OF bapiret2,

  i_itext TYPE TABLE OF bapi_alm_text,

  i_text TYPE TABLE OF bapi_alm_text_lines,

  wa_text TYPE bapi_alm_text_lines,

  wa_itext TYPE bapi_alm_text.

DATA: wa_methods TYPE bapi_alm_order_method,

  wa_header TYPE bapi_alm_order_headers_i,

  wa_headerup TYPE bapi_alm_order_headers_up,

  wa_component TYPE bapi_alm_order_component,

  wa_componentup TYPE bapi_alm_order_component_up,

  wa_return TYPE bapiret2,

  lv_aufnr TYPE aufnr,

  lv_vornr TYPE vornr,

  lv_text(132) TYPE c,

  gv_int TYPE i.

PARAMETERS: P_TEST AS CHECKBOX.

CLEAR: i_methods[], i_header[], i_headerup[],

  i_component[], i_componentup[], i_return[].

*CLEAR: v_objkey.

CLEAR: lv_aufnr.

lv_aufnr = '1015931'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  EXPORTING

  input = lv_aufnr

  IMPORTING

  output = lv_aufnr.

*************************************

*lv_vornr = '10'.

*CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

* EXPORTING

* input = lv_vornr

* IMPORTING

* output = lv_vornr.

*

*lv_text = 'Testing Workorder TET TES TES TES TEST TEST TES TEST TEST'.

*wa_text-tdformat = '*'.

*wa_text-tdline = lv_text.

*APPEND wa_text TO i_text.

*

*DESCRIBE TABLE i_text LINES gv_int.

*

*wa_itext-orderid = lv_aufnr. "(Order Number)

*wa_itext-activity = lv_vornr. "(Operation)

*wa_itext-langu = 'E'.

*wa_itext-textstart = '1'.

*wa_itext-textend = gv_int. " last line number, ntg but number of entries in the table et_tline

*APPEND wa_itext TO i_itext.

*

*

*wa_methods-refnumber = '000001'.

*wa_methods-objecttype = 'TEXT'.

*wa_methods-method = 'CREATE'.

*CONCATENATE lv_aufnr lv_vornr INTO wa_methods-objectkey

* IN CHARACTER MODE.

*APPEND wa_methods TO i_methods.

**************************************************************************************

wa_methods-refnumber = '000001'.

wa_methods-objecttype = 'COMPONENT'.

wa_methods-method = 'CREATE'.

wa_methods-objectkey = lv_aufnr.

APPEND wa_methods TO i_methods.

wa_methods-refnumber = '000002'.

wa_methods-objecttype = 'COMPONENT'.

wa_methods-method = 'CREATE'.

wa_methods-objectkey = lv_aufnr.

APPEND wa_methods TO i_methods.

wa_methods-refnumber = '000003'.

wa_methods-objecttype = 'COMPONENT'.

wa_methods-method = 'CREATE'.

wa_methods-objectkey = lv_aufnr.

APPEND wa_methods TO i_methods.

wa_methods-objecttype = ' '.

wa_methods-method = 'SAVE'.

APPEND wa_methods TO i_methods.

**Component Internal table

*wa_component-reserv_no = '0000019761'.

*wa_component-res_item = '0002'.

*wa_component-activity = '0010'.

wa_component-item_number = '0010'.

wa_component-material = 'FF013-003'.

wa_component-plant = '3000'.

wa_component-requirement_quantity = '1'.

wa_component-stge_loc = '0003'.

wa_component-gl_account = '661100'.

wa_component-preq_name = '100063'.

wa_component-price = '123'.

wa_component-price_unit = '1'.

wa_component-currency = 'USD'.

APPEND wa_component TO i_component.

**Component Internal table

*wa_component-reserv_no = '0000019761'.

*wa_component-res_item = '0002'.

*wa_component-activity = '0010'.

wa_component-item_number = '0020'.

wa_component-material = 'FM901-000'.

wa_component-plant = '3000'.

wa_component-requirement_quantity = '2'.

wa_component-stge_loc = '0003'.

wa_component-gl_account = '661100'.

wa_component-preq_name = '100063'.

wa_component-price = '15'.

wa_component-price_unit = '1'.

wa_component-currency = 'USD'.

APPEND wa_component TO i_component.

**Component Internal table

*wa_component-reserv_no = '0000019761'.

*wa_component-res_item = '0002'.

*wa_component-activity = '0010'.

wa_component-item_number = '0030'.

wa_component-material = 'FM901-000'.

wa_component-plant = '3000'.

wa_component-requirement_quantity = '5'.

wa_component-stge_loc = '0003'.

wa_component-gl_account = '661100'.

wa_component-preq_name = '100063'.

wa_component-price = '20'.

wa_component-price_unit = '1'.

wa_component-currency = 'USD'.

APPEND wa_component TO i_component.

wa_componentup-item_number = 'X'.

wa_componentup-material = 'X'.

wa_componentup-plant = 'X'.

wa_componentup-requirement_quantity = 'X'.

wa_componentup-stge_loc = 'X'.

wa_componentup-gl_account = 'X'.

wa_componentup-preq_name = 'X'.

wa_componentup-price = 'X'.

wa_componentup-price_unit = 'X'.

wa_componentup-currency = 'X'.

APPEND wa_componentup TO i_componentup.

wa_header-orderid = lv_aufnr.

*wa_header-order_type = 'SC01'.

*wa_header-planplant = '3000'.

APPEND wa_header TO i_header.

wa_headerup-orderid = 'X'.

*wa_headerup-order_type = 'X'.

*wa_headerup-planplant = 'X'.

APPEND wa_headerup TO i_headerup.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

TABLES

it_methods = i_methods

it_header = i_header

it_header_up = i_headerup

* IT_HEADER_SRV =

* IT_HEADER_SRV_UP =

* IT_USERSTATUS =

* IT_PARTNER =

* IT_PARTNER_UP =

* IT_OPERATION = I_OPERATION

* IT_OPERATION_UP = I_OPERATIONUP

* IT_RELATION =

* IT_RELATION_UP =

*it_component = i_component

*it_component_up = i_componentup

* it_text = i_itext

* it_text_lines = i_text

* EXTENSION_IN =

* return = i_return

* ET_NUMBERS =

.

READ TABLE i_return INTO wa_return WITH KEY type = 'E'.

IF sy-subrc NE 0.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  WAIT UP TO 1 SECONDS.

ELSE.

  MOVE lv_aufnr TO wa_msg_log-aufnr.

  MOVE wa_return-message TO wa_msg_log-message.

  APPEND wa_msg_log TO it_msg_log.

  CLEAR: wa_msg_log.

ENDIF.

**********************************************************************

CLEAR: i_methods[], i_header[], i_headerup[],

  i_component[], i_componentup[], i_return[].

DATA: it_resb TYPE STANDARD TABLE OF resb,

  lx_resb TYPE resb.

SELECT *

FROM resb

INTO TABLE it_resb

WHERE aufnr = lv_aufnr

  AND xloek = space.

wa_methods-objecttype = ' '.

wa_methods-method = 'SAVE'.

APPEND wa_methods TO i_methods.

LOOP AT it_resb INTO lx_resb.

* wa_methods-refnumber = sy-tabix.

* wa_methods-objecttype = 'COMPONENT'.

* wa_methods-method = 'CHANGE'.

* wa_methods-objectkey = lv_aufnr.

* APPEND wa_methods TO i_methods.

**Component Internal table

* wa_component-reserv_no = lx_resb-rsnum.

* wa_component-res_item = lx_resb-rspos.

* wa_component-item_number = '0010'.

* APPEND wa_component TO i_component.

*

* wa_componentup-item_number = 'X'.

* APPEND wa_componentup TO i_componentup.

  lv_text = 'Testing Workorder TET TES TES TES TEST TEST TES TEST TEST'.

  wa_text-tdformat = '*'.

  wa_text-tdline = lv_text.

  APPEND wa_text TO i_text.

  DESCRIBE TABLE i_text LINES gv_int.

  wa_itext-orderid = lv_aufnr. "(Order Number)

* wa_itext-activity = lv_vornr. "(Operation)

  wa_itext-reserv_no = lx_resb-rsnum.

  wa_itext-res_item = lx_resb-rspos.

  wa_itext-res_type = lx_resb-rsart.

  wa_itext-langu = 'E'.

  wa_itext-textstart = '1'.

  wa_itext-textend = gv_int. " last line number, ntg but number of entries in the table et_tline

  APPEND wa_itext TO i_itext.

  wa_methods-refnumber = '000001'.

  wa_methods-objecttype = 'TEXT'.

  wa_methods-method = 'CREATE'.

  CONCATENATE lv_aufnr '' INTO wa_methods-objectkey

  IN CHARACTER MODE.

  APPEND wa_methods TO i_methods.

  EXIT.

ENDLOOP.

wa_header-orderid = lv_aufnr.

APPEND wa_header TO i_header.

wa_headerup-orderid = 'X'.

APPEND wa_headerup TO i_headerup.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

  TABLES

  it_methods = i_methods

  it_header = i_header

  it_header_up = i_headerup

* IT_HEADER_SRV =

* IT_HEADER_SRV_UP =

* IT_USERSTATUS =

* IT_PARTNER =

* IT_PARTNER_UP =

* IT_OPERATION = I_OPERATION

* IT_OPERATION_UP = I_OPERATIONUP

* IT_RELATION =

* IT_RELATION_UP =

*it_component = i_component

*it_component_up = i_componentup

  it_text = i_itext

  it_text_lines = i_text

* EXTENSION_IN =

  return = i_return

* ET_NUMBERS =

  .

READ TABLE i_return INTO wa_return WITH KEY type = 'E'.

IF sy-subrc NE 0.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  WAIT UP TO 1 SECONDS.

ELSE.

  MOVE lv_aufnr TO wa_msg_log-aufnr.

  MOVE wa_return-message TO wa_msg_log-message.

  APPEND wa_msg_log TO it_msg_log.

  CLEAR: wa_msg_log.

ENDIF.

DATA: o_salv TYPE REF TO cl_salv_table.

TRY.

  CALL METHOD cl_salv_table=>factory

  IMPORTING

  r_salv_table = o_salv

  CHANGING

  t_table = i_return.

  CATCH cx_salv_msg .

ENDTRY.

o_salv->display( ).

0 Kudos

Thanks Ashwin, But it is updating long text only for 1st component. If i have 4 components, then

i am populating method table like this:

Please help what should be values here.

I was on vacations so could not check your reply.

0 Kudos

Hello Ashwin,

Finally issue got solved. What mistake i did, i passed refnum as 000001 in all the lines, but it should be 000001,000002...so on for each component long text. also in IT_TEXT table we need to pass like that:

TEXTSTAR TEXTEND

00000001 00000002  ===>Component 1

00000003 00000004 ===> Component 2

00000005 00000006 ===> Component 3

00000007 00000008 === > component 4

This indicates that first two lines from table IT_TEXT_LINES belongs to component 1 and so on.

Thanks a lot for your help. You solved a big question that i could not find over the internet.

Regards,

Ashish T.

former_member212854
Participant
0 Kudos

Hi Ashish,

Sorry of the delay.

First part of code(1st BAPI call) is for Component creation for the work order and second part(2nd BAPI call  of the code is to create long text for one of the component.

Hope this helps.

Regards,

Ashwin.