Skip to Content

Purpose

This Document demonstrates the use of FM OIJ02_CREATE_TICKT with the latest release [ I am using mySAP ECC 6.0 EHP 6 ].

And also demonstrates the use of OIJB_TKT_QCI_INTERFACE for quantity conversion parameters of SAP IS Oil.

No documentation is available for this FM in SAP.

The FM is used to post ticket against nomination and encapsulates the entire functionality into one [Earlier we needed 3 FM calls to achive the same].

Transactions

O4NSN & O4TGN for display of Nomination and Ticket.

How to achieve :

    DATA : lw_tkt_h          TYPE  roij_el_ticket_hvb,

           lw_tkt_si         TYPE  roijnomsubitems_io,

           lw_oijnomh        TYPE  oijnomh,

           lw_oijnomi        TYPE  oijnomi,

           lw_return         TYPE  bapiret2,

           lw_act_flag       TYPE  c VALUE ‘X’,

           lw_tcount         TYPE  n LENGTH 4,

           lw_i_o1           TYPE  roij_el_tkt_i_o1,

           lw_i_o2           TYPE  roij_el_tkt_i_o2vb,

           lt_tkt_i          TYPE  TABLE OF roij_el_ticket_i_io,

           lw_tkt_i          TYPE  roij_el_ticket_ivb,

           lt_tkt_si         TYPE  TABLE OF roijnomsubitems_io,

           lt_i_o1           TYPE  TABLE OF roij_el_tkt_i_o1,

           lt_i_o2           TYPE  TABLE OF roij_el_tkt_i_o2vb,

           lt_return         TYPE  TABLE OF bapiret2.

Get the Nomination Details.

    SELECT SINGLE * FROM oijnomh INTO lw_oijnomh
                                WHERE nomtk = lw_g_odet-nomtk.

    SELECT SINGLE * FROM oijnomi INTO lw_oijnomi
                                WHERE nomtk = lw_g_odet-nomtk
                                  AND nomit = lw_g_odet-nomit.

Pass the values to the corresponding structure.

    SELECT COUNT(*) INTO lw_tcount FROM oij_el_ticket_i
                                  WHERE nomtk = lw_g_odet-nomtk
                                    AND nomit = lw_g_odet-nomit.

    lw_tkt_h-tplst          = lw_oijnomh-tplst.
    lw_tkt_h-tsyst          = lw_oijnomh-tsyst.
    lw_tkt_h-erdat          = sy-datum.
    lw_tkt_h-erzeit         = sy-uzeit.
    lw_tkt_h-ernam          = sy-uname.

    ADD 1 TO lw_tcount.

    CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT’
      EXPORTING
        input  = lw_g_odet-nomtk
      IMPORTING
        output = lw_tkt_h-ticketnr.

* External Ticket Identifier

    CONCATENATE lw_tkt_h-ticketnr
                lw_g_odet-nomit+7(3)
                lw_tcount
           INTO lw_tkt_h-ticketnr
      SEPARATED BY ‘_’. 

    lw_tkt_h-ticket_type    = ‘YRT’.
    lw_tkt_h-ticket_version = 00.
    lw_tkt_h-ticket_purpose = 01.
    lw_tkt_h-updkz          = ‘I’.

*   Populating the Item table for ticket posting

    lw_tkt_i-nomtk            = lw_g_odet-nomtk.
    lw_tkt_i-nomit            = lw_g_odet-nomit.

This indicator is to be passed if you want to close the nomination line item

*    lw_tkt_i-close_nomit      = ‘X’.

    lw_tkt_i-vehicle          = lw_g_odet-vehid.
    lw_tkt_i-nomnr            = lw_oijnomh-nomnr.
    lw_tkt_i-matnr            = lw_oijnomi-matnr_i.
    lw_tkt_i-locid            = lw_oijnomi-locid.
    lw_tkt_i-substatus        = lw_oijnomi-isubstat.
    lw_tkt_i-sityp            = lw_oijnomi-sityp.
    lw_tkt_i-charg_l          = lw_oijnomi-charg_l.
    lw_tkt_i-charg_d          = lw_oijnomi-charg_d.
    lw_tkt_i-charg_o          = lw_oijnomi-charg_o.

The scenario is the identifier which states whether the process is outbound or inbound

Depending on this the Source Plant / SLoc or Destination Plant / Sloc is filled.

    SELECT SINGLE mvscenario FROM toij_el_mvscen
                             INTO lw_tkt_i-mvscenario
                            WHERE sityp         = lw_oijnomi-sityp
                              AND docind        = lw_oijnomi-docind
                              AND book_transfer = space.

    IF p_omode = 7.
      lw_tkt_i-werks_o          = lw_oijnomi-locpt.
      lw_tkt_i-lgort_o          = lw_oijnomi-locsl.
    ELSEIF p_omode = 3.
      lw_tkt_i-werks_d          = lw_oijnomi-locpt.
      lw_tkt_i-lgort_d          = lw_oijnomi-locsl.
    ENDIF.


    lw_tkt_i-time_st_led_ot   = lw_tkt_i-time_st_load_sta.
    lw_tkt_i-ticket_item      = 10.
    lw_tkt_i-ticket_version   = 00.
    lw_tkt_i-ticket_purpose   = 01.
    lw_tkt_i-updkz            = ‘I’.

    CONCATENATE sy-datum sy-uzeit INTO lw_tkt_i-time_st_load_sta.
    lw_tkt_i-oib_bltime = sy-uzeit + ‘000001’.

    CONCATENATE sy-datum lw_tkt_i-oib_bltime INTO lw_tkt_i-time_st_load_end.

    IF sy-uzeit LT ‘060000’.
      lw_tkt_i-budat          = sy-datum – 1.
      lw_tkt_i-oib_bltime     = ‘115500’.
    ELSE.
      lw_tkt_i-budat          = sy-datum.
      lw_tkt_i-oib_bltime     = sy-uzeit.
    ENDIF.

If you are using sub-items as in my case is a rail scenario so I am passing the sub-items as well

It is not a mandatory parameter, as in Vessel case there won’t be any so it can be skipped.

    LOOP AT lt_subitems ASSIGNING <lfs_item>.

      IF <lfs_item>-subitm_actqty IS NOT INITIAL
     AND <lfs_item>-carr_tkt_key  IS INITIAL.

        <lfs_item>-ticket_item    = lw_tkt_i-ticket_item.
        <lfs_item>-ticket_version = lw_tkt_i-ticket_version.
        <lfs_item>-ticket_purpose = lw_tkt_h-ticket_purpose.
        <lfs_item>-act_date       = sy-datum.
        <lfs_item>-act_time       = sy-uzeit.

        MOVE-CORRESPONDING <lfs_item> TO lw_tkt_si.         “#EC ENHOK

        lw_tkt_si-updkz           = ‘U’.

        APPEND lw_tkt_si TO lt_tkt_si.

        lw_tkt_i-menge = lw_tkt_i-menge + <lfs_item>-subitm_actqty.
        lw_tkt_i-meins = <lfs_item>-subitm_actuom.

        IF <lfs_item>-zz_dip_temp IS NOT INITIAL.
          IF lw_tkt_i-tstmp IS INITIAL.
            lw_tkt_i-tstmp = <lfs_item>-zz_dip_temp .
          ELSE.
            lw_tkt_i-tstmp = ( lw_tkt_i-tstmp + <lfs_item>-zz_dip_temp ) / 2.
          ENDIF.
        ENDIF.

        IF <lfs_item>-zz_dip_den IS NOT INITIAL.
          IF lw_tkt_i-tdich IS INITIAL.
            lw_tkt_i-tdich = <lfs_item>-zz_dip_den.
          ELSE.
            lw_tkt_i-tdich = ( lw_tkt_i-tdich + <lfs_item>-zz_dip_den ) / 2.
          ENDIF.
        ENDIF.

      ENDIF.

    ENDLOOP.

    IF lt_tkt_si IS INITIAL.
      MESSAGE text-050 TYPE ‘I’.
      RETURN.
    ENDIF.

    APPEND lw_tkt_i TO lt_tkt_i.

The QCI parameters are an important part of the entire IS-Oil scenario so for that conversion the below FM is used.

    CALL FUNCTION ‘OIJB_TKT_QCI_INTERFACE’
      EXPORTING
        is_working             = ‘H’
        is_ticket_header       = lw_tkt_h
        is_ticket_item         = lw_tkt_i
        is_nomination_header   = lw_oijnomh
        is_nomination_item     = lw_oijnomi
      CHANGING
        cs_oij_el_tkt_i_o1     = lw_i_o1
        ct_oij_el_tkt_i_o2     = lt_i_o2
        return                 = lt_return
      EXCEPTIONS
        ticket_item_unit_error = 1
        OTHERS                 = 2.

    IF sy-subrc <> 0.
      IF sy-msgid IS INITIAL.
        MESSAGE i016(rp) WITH text-e03 .
      ELSE.
        MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CLEAR lw_act_flag.
    ENDIF.

The ACT flag for the actualization of the ticket if you want to actualize it later keep it blank.

    CHECK lw_act_flag EQ ‘X’.

This is an important part… In my case I am not passing the QCI Defaults so If we are changing the defaults

The manual indicator needs to be flagged.

    lw_i_o1-mttmp = lw_tkt_i-tstmp.
    lw_i_o1-tdich = lw_tkt_i-tdich.

    lw_i_o2-manen = ‘X’.
    MODIFY lt_i_o2 FROM lw_i_o2 TRANSPORTING manen WHERE manen = space .

    APPEND  lw_i_o1 TO lt_i_o1.

The below sort is compulsory as without it internally some read fails

    SORT lt_i_o2 BY ticket_key     ticket_item
                    ticket_version ticket_purpose msehi.

    CALL FUNCTION ‘OIJ02_CREATE_TICKT’
      EXPORTING
        flag_actualization = lw_act_flag
      CHANGING
        gs_h               = lw_tkt_h
        gt_i               = lt_tkt_i
        gt_si              = lt_tkt_si
        gt_i_o2            = lt_i_o2
        gt_i_o1            = lt_i_o1
        lt_bapi_return     = lt_return.

    READ TABLE lt_return INTO lw_return WITH KEY number = ‘850’
                                                   type = ‘S’.

    IF sy-subrc IS NOT INITIAL.
      READ TABLE lt_return INTO lw_return WITH KEY type = ‘E’.
      ROLLBACK WORK.
    ELSE.
      COMMIT WORK AND WAIT.
    ENDIF.

    IF lw_return IS NOT INITIAL.
      MESSAGE ID lw_return-id
            TYPE lw_return-type
          NUMBER lw_return-number
            WITH lw_return-message_v1 lw_return-message_v2.
    ENDIF.


To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

    1. Former Member

      Hi Dear,

      Document is very useful.

      To update further, about meter ticket we have GMMNR,, events and reading fields to populate in GT_I.

      Does any one know if we have inbound IDOC also to create meter ticket.

      Regards,

      Kamal  Jain

      (0) 

Leave a Reply