SAP for Oil, Gas, and Energy Discussions
Connect with fellow SAP users to share best practices, troubleshoot challenges, and navigate the evolving energy landscape. Join the conversation today!
cancel
Showing results for 
Search instead for 
Did you mean: 

TSW-Ticket Creation & Actualization using BDC

0 Kudos

Hi,

I am using BDC for Ticket creation using transaction O4TEN.

After execution of this BDC, Ticket get created and Saved but it does not actualize ticket even if we click actualize button using BDC.

In real scenario, after ticket creation the status and substatus values should be "C"(Planned) and "6" (Complete) but in this case the status and substatus values are "B"(Checked) and "4"(Positive).

If we create ticket directly using O4TEN then it actualizes ticket properly.

I am not able to find out why BDC is not actualizing tickets.

Any idea?

Regards,

Umesh

6 REPLIES 6

Former Member
0 Kudos

Umesh,

You will not be able to actualize the ticket using BDC because of different checks inside the actualization programs.

Try using the function module "OIJB_GENERATE_DOCUMENTS_N" for actualizing the ticket.

In a simple way. After the ticket is saved, get the ticket key. Read the ticket header, item, OIJ_EL_TKT_I_O1, OIJ_EL_TKT_I_O2, Nom header & item details from the database for this ticket and then use these details to call the function OIJB_GENERATE_DOCUMENTS_N.

Do not forget to commit after calling the function if there are no errors returned.

Best Regards

Vishnu

0 Kudos

Hi Vishnu,

After BDC call transaction I get sy-subrc = 0. but it does not return any message with Ticket Key generated.

How do we get this ticket Key? Do we need to Commit after Call transaction as well?

Regards,

Umesh

0 Kudos

Umesh,

Are you still trying to actualize the ticket inside the BDC.

If you are then you should change the BDC to only save the ticket and not actualize. If you do this then you should be able to get the ticket number or key in the message. You can then use this for actualizing the ticket

I have never used BDC for creating the ticket. I have used the function module OIJ_EL_A_TICKETS_MAINTAIN_N for creating the ticket and then OIJB_GENERATE_DOCUMENTS_N for actualizing the ticket.

You can try with the BDC. I hope it should work. If you do not want to use the function module in any case then you should be able to get the ticket number from the nomination with some conditions for getting the ticket in case of multiple tickets against the nomination item.

Best Regards

Vishnu

0 Kudos

Hi,

I tried BDC for SAVE but still not getting Ticket Key.

So now I am using FM: OIJ_EL_A_TICKETS_MAINTAIN_N.

It creates ticket but in Ticket Item table Ticket item field is blank. Purpose is blank.

Also OIJ_EL_TKT_I_O1 and OIJ_EL_TKT_I_O2 are not populated.

In header I am passing: TICKET_PURPOSE, TICKET_TYPE, UPDKZ = 'I'

and In item I am passing: NOMNR, NOMTK, NOMIT, MENGE, MEINS, TIME_ST_LOAD_STA, TIME_ST_LOAD_END, BUDAT UPDKZ = 'I'.

am I missing something?

Code is as follows:

    • Replace BDC with function module: OIJ_EL_A_TICKETS_MAINTAIN_N

    • 1) Call FM: OIJ_EL_A_TICKETS_MAINTAIN_N

    • 2) Call FM: ENQUEUE_E_OIJTKT

    • 3) Call FM: OIJB_GENERATE_DOCUMENTS_N

    • 4) Call FM: DEQUEUE_E_OIJTKT

*

DATA: ls_tkt_h TYPE roij_el_ticket_hvb,

ls_tkt_i TYPE roij_el_ticket_i_io,

ls_oijnomi TYPE oijnomi,

ls_roijnomiio TYPE roijnomiio,

ls_ticket_item TYPE oij_el_ticket_i,

ls_ticket_item_o1 TYPE oij_el_tkt_i_o1,

ls_ticket_item_o2 TYPE oij_el_tkt_i_o2,

ls_ticket_header_pv TYPE oij_el_ticket_h,

ls_ticket_header TYPE oij_el_ticket_h,

ls_tkt_i_o1 TYPE oij_el_tkt_i_o1,

ls_tkt_i_o2 TYPE oij_el_tkt_i_o2.

DATA: lv_time TYPE sy-uzeit.

DATA: it_tkt_i TYPE roij_el_ticket_i_io_t,

it_tkt_h_evt TYPE roijte_t,

it_tkt_h_evt_txt TYPE oij_txt,

it_tkt_i_evt TYPE roijte_t,

it_tkt_i_evt_txt TYPE oij_txt,

it_tkt_i_o1 TYPE roij_el_tkt_i_o1_t,

it_tkt_i_o2 TYPE roij_el_tkt_i_o2_t,

it_tkt_err_log TYPE oij_el_err_log_tt,

it_tkt_doc_flow TYPE roij_el_doc_flow_io_t,

it_return TYPE bapiret2_t,

it_oijnomh TYPE oijnomh_t,

it_oijnomi TYPE oijnomi_t,

it_ticket_item TYPE STANDARD TABLE OF oij_el_ticket_i,

it_ticket_item_o1 TYPE STANDARD TABLE OF oij_el_tkt_i_o1,

it_ticket_item_o2 TYPE STANDARD TABLE OF oij_el_tkt_i_o2.

ls_tkt_h-ticket_purpose = '1'.

ls_tkt_h-ticket_type = lv_ticket_type.

IF lv_ticket_type EQ c_yp2.

  • If Ticket type is YP2 then

ls_tkt_h-yy_mct_cat = fp_mct_cat.

ENDIF.

ls_tkt_h-yy_pat_alc = lv_alloc_rule.

ls_tkt_h-updkz = 'I'.

ls_tkt_i-nomnr = fp_s_tc1-nomnr.

ls_tkt_i-nomtk = fp_s_tc1-nomtk.

ls_tkt_i-nomit = fp_s_tc1-nomit.

ls_tkt_i-menge = lv_menge.

ls_tkt_i-meins = fp_s_tc1-units.

CLEAR ls_oijnomi.

SELECT SINGLE * FROM oijnomi INTO ls_oijnomi

WHERE nomtk = fp_s_tc1-nomtk

AND nomit = fp_s_tc1-nomit.

IF sy-subrc EQ 0.

MOVE-CORRESPONDING ls_oijnomi TO ls_roijnomiio.

ENDIF.

PERFORM get_timestamp USING fp_sdate

lv_time

ls_roijnomiio

CHANGING ls_tkt_i-time_st_load_sta.

PERFORM get_timestamp USING fp_edate

lv_time

ls_roijnomiio

CHANGING ls_tkt_i-time_st_load_end.

CONCATENATE lv_budat(4) lv_budat5(2) lv_budat8(2) INTO ls_tkt_i-budat.

ls_tkt_i-updkz = 'I'.

APPEND ls_tkt_i TO it_tkt_i.

CALL FUNCTION 'OIJ_EL_A_TICKETS_MAINTAIN_N'

EXPORTING

is_tkt_header = ls_tkt_h

  • IT_HEADER_EVT =

  • IT_HEADER_EVT_TXT =

it_items = it_tkt_i

  • IT_ITM_EVT =

  • IT_ITM_EVT_TXT =

  • IT_ITM_O1 =

  • IT_ITM_O2 =

  • IT_TKT_ERROR_LOG =

it_tkt_doc_flow = it_tkt_doc_flow

iv_commit = 'X'

  • IV_LOCK =

  • IV_ADD_TO_LOG =

  • IV_CALL_TO_OUTPUT =

IMPORTING

es_tkt_header = ls_tkt_h

  • ET_HEADER_EVT = it_tkt_h_evt

  • ET_HEADER_EVT_TXT = it_tkt_h_evt_txt

et_items = it_tkt_i

  • ET_ITM_EVT = it_tkt_i_evt

  • ET_ITM_EVT_TXT = it_tkt_i_evt_txt

et_itm_o1 = it_tkt_i_o1

et_itm_o2 = it_tkt_i_o2

  • ET_TKT_ERROR_LOG = it_tkt_err_log

et_tkt_doc_flow = it_tkt_doc_flow

et_return = it_return

EXCEPTIONS

ticket_locked = 1

OTHERS = 2

.

IF sy-subrc NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

COMMIT WORK AND WAIT.

  • Lock the ticket

  • There is no check neccessary if the ticket has already

  • been locked by an other user because it has just been

  • created.

CALL FUNCTION 'ENQUEUE_E_OIJTKT'

EXPORTING

mode_oij_el_ticket_h = 'E'

mandt = sy-mandt

ticket_key = ls_tkt_h-ticket_key

ticket_version = ls_tkt_h-ticket_version

ticket_purpose = ls_tkt_h-ticket_purpose

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDIF.

CALL FUNCTION 'OIJB_GET_NOMINATION_DATA'

EXPORTING

  • ACTIVITY =

is_ticket_header = ls_tkt_h

is_ticket_item = ls_tkt_i

  • IV_ADD_TO_LOG =

CHANGING

ct_oijnomh = it_oijnomh

ct_oijnomi = it_oijnomi

  • RETURN =

EXCEPTIONS

ticket_data_error = 1

no_nomination_selected = 2

OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ls_ticket_header = ls_tkt_h.

LOOP AT it_tkt_i INTO ls_tkt_i.

MOVE-CORRESPONDING ls_tkt_i TO ls_ticket_item.

APPEND ls_ticket_item TO it_ticket_item.

ENDLOOP.

LOOP AT it_tkt_i_o1 INTO ls_tkt_i_o1.

MOVE-CORRESPONDING ls_tkt_i_o1 TO ls_ticket_item_o1.

APPEND ls_ticket_item_o1 TO it_ticket_item_o1.

ENDLOOP.

LOOP AT it_tkt_i_o2 INTO ls_tkt_i_o2.

MOVE-CORRESPONDING ls_tkt_i_o2 TO ls_ticket_item_o2.

APPEND ls_ticket_item_o2 TO it_ticket_item_o2.

ENDLOOP.

CALL FUNCTION 'OIJB_GENERATE_DOCUMENTS_N'

EXPORTING

i_ticket_header = ls_ticket_header

i_ticket_header_pv = ls_ticket_header_pv

  • I_CLOSE_SHIPMENT = ' '

TABLES

t_ticket_item = it_ticket_item

t_ticket_item_o1 = it_ticket_item_o1

t_ticket_item_o2 = it_ticket_item_o2

  • T_TICKET_ITEM_PV =

  • T_TICKET_ITEM_O1_PV =

  • T_TICKET_ITEM_O2_PV =

t_oijnomh = it_oijnomh

t_oijnomi = it_oijnomi

  • T_DOC_FLOW =

  • T_ERR_LOG =

  • T_REVERSAL_DOCS =

  • T_ORIGINAL_DOCS =

  • T_TICKET_SUBITEM =

EXCEPTIONS

error_during_cip_process = 1

error_during_checks = 2

nomination_lock_error = 3

nomination_read_error = 4

cip_process_read_error = 5

OTHERS = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

COMMIT WORK AND WAIT.

ENDIF.

0 Kudos

Umesh,

We are using the same process and everything is working fine.

The only change i can see is that we are passing iv_commit as space and iv_lock also as space when calling the function module OIJ_EL_A_TICKETS_MAINTAIN_N.

We are getting the ticket header & item tables filled in after the function call.

I did not go through the full code of yours as i am busy this week.

Try to change the function call and see if it works. Otherwise try to debug the function and see what is missing out there..

Best Regards

Vishnu

0 Kudos

Hi Umesh,

Have u got solution. Pls tell me how u have done that, I also have similar requirement.

Thanks

Jitendra