Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2878

Re: Upload Order Operation's component long text

$
0
0

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( ).


Viewing all articles
Browse latest Browse all 2878

Trending Articles