SAP for Utilities Discussions
Connect with fellow SAP users to share best practices, troubleshoot challenges, and collaborate on building a sustainable energy future. Join the discussion.
cancel
Showing results for 
Search instead for 
Did you mean: 

IS-U User Exit Event R402 (Billing)

marcushautz
Explorer
0 Kudos

This question goes to anyone, who already had experience with the IS-U event R402. (ISU_SAMPLE_R402)

To create a new DOC while in the billing process, the documentation advises you to use the parameter Y_VKK_DOC_NEW. To modify or delete existing docs you should use the table parameter T_VKK_DOC_ID, which holds all current docs.

Let's assume that I am not allowed to use the flat structure to create a new doc.

Is there any way to use the table T_VKK_DOC_ID instead ? I tried to append a line there and filled up all necessary data. The billing process went fine, but the new doc doesnt show up in the bill.

I'd appreciate any hints / documentation or some sample coding.

5 REPLIES 5

Former Member
0 Kudos

Hi,

We used this event to create a line in the invocing document.

Bellow is spined of the code we used:

Hope it will help you.

Daniel

DATA: y_vkk_doc_id_r402 TYPE isu21_t_vkk_doc_id_r402.

DATA: l_nettobtr LIKE erdz-nettobtr.

DATA: lt_op TYPE fkkop OCCURS 0, "CA

lt_op_one_contr TYPE fkkop OCCURS 0 WITH HEADER LINE, "contract

l_op LIKE fkkop,

l_opupk_ix LIKE sy-tabix. "index of DPR items of contr.acc.

DATA: lt_te417 LIKE te417 OCCURS 0 WITH HEADER LINE.

DATA: l_portion LIKE te422-portion.

DATA: l_blart LIKE fkkko-blart,

l_waers LIKE fkkop-waers VALUE 'RON'.

  • external represetation of main transaction and sub-transacton of DPR

DATA: l_hvorg LIKE teivv-hvorg,

l_tvorg LIKE teivv-tvorg.

DATA: l_begabrpe LIKE lt_te417-termtdat, "Begin und Ende Abrechnungs

l_endabrpe LIKE lt_te417-endvoper.

DATA: l_bill_doc_hochrech TYPE isu2a_bill_doc.

  • ls_bill_doc_extrapol_ops TYPE /sapce/iu_bbic_billdoc_ops.

  • billing documents

DATA: lt_bill_doc TYPE isu2a_t_bill_doc,

l_wa_bill_doc TYPE isu2a_bill_doc.

DATA: l_t001 LIKE t001.

DATA: l_rt_faedn TYPE fkkr_faedn, "Range Table fuer FAEDN

lt_rt_faedn TYPE fkk_rt_faedn.

DATA: lt_dfkkop LIKE dfkkop OCCURS 0.

DATA: l_te557 LIKE te557.

DATA: l_te757 LIKE te757.

DATA: l_te633 LIKE te633.

DATA: lt_contrcl LIKE t_contrcl OCCURS 0 WITH HEADER LINE.

DATA: lt_eitr LIKE eitr OCCURS 0 WITH HEADER LINE. "Faktur.trigger

DATA: lt_erch LIKE erch OCCURS 0 WITH HEADER LINE.

DATA: lw_erdz LIKE erdz.

DATA: lw_fkkopk LIKE fkkopk.

DATA: lw_zroisu002 LIKE zroisu002.

CLEAR: lw_fkkopk.

SELECT SINGLE * INTO lw_zroisu002

FROM zroisu002.

IF sy-subrc <> 0.

MESSAGE e012(zroisu) RAISING error_message.

EXIT.

ENDIF.

    • beispiel lesen aller belege einer id

PERFORM read_vkk_doc_id_r402 TABLES t_vkk_doc_id

y_vkk_doc_id_r402

USING co_vkkdoc_main.

LOOP AT y_vkk_doc_id_r402 INTO wa_vkk_doc_id_r402.

PERFORM read_vkk_doc_r402 TABLES t_vkk_doc_id

USING co_vkkdoc_main

wa_vkk_doc_id_r402-tmp_belnr

wa_vkk_doc_r402.

ENDLOOP.

LOOP AT x_invoice_unit-print_doc-t_erdz

INTO lw_erdz

WHERE belzart = lw_zroisu002-belzart.

ADD lw_erdz-nettobtr TO l_nettobtr.

ENDLOOP.

IF l_nettobtr IS INITIAL.

EXIT.

ENDIF.

l_hvorg = lw_zroisu002-hvorg.

l_tvorg = lw_zroisu002-tvorg.

l_blart = lw_zroisu002-blart.

  • create local copy of contracts and sort them

lt_contrcl[] = t_contrcl[].

READ TABLE lt_contrcl INDEX 1.

      • build DPR item (OP)

CLEAR l_op.

l_op-bukrs = lt_contrcl-bukrs.

l_op-gpart = x_bupa-partner.

l_op-vkont = x_fkkvkp-vkont.

l_op-spart = lt_contrcl-sparte.

  • convert contract to FI-CA contract reference

CALL FUNCTION 'ISU_INTERNAL_VERTRAG_TO_VTREF'

EXPORTING

i_vertrag = lt_contrcl-vertrag

IMPORTING

e_vtref = l_op-vtref.

SELECT SINGLE fun01 INTO l_op-hkont

FROM tfk033d

WHERE applk = 'R'

AND buber = 'R000'

AND ktopl = 'GAZ'

AND key01 = lt_contrcl-bukrs

AND key02 = lt_contrcl-sparte

AND key03 = lt_contrcl-kofiz

AND key04 = lw_zroisu002-hvorg.

CHECK sy-subrc = 0.

l_op-applk = co_applk_isu.

l_op-hvorg = lw_zroisu002-hvorg.

l_op-tvorg = lw_zroisu002-tvorg.

l_op-kofiz = lt_contrcl-kofiz.

l_op-bldat = x_bldat.

l_op-budat = x_budat.

l_op-waers = l_waers.

l_op-blart = lw_zroisu002-blart.

l_op-fdgrp = x_fkkvkp-fdgrp. "CashManagement - planning group

l_op-opupk = 1.

  • l_op-hkont = lw_zroisu002-hkont.

l_op-betrh = 0 - l_nettobtr.

l_op-betrw = 0 - l_nettobtr.

  • get LAND1 for further determination of MWSKZ

SELECT SINGLE * FROM t001 INTO l_t001

WHERE bukrs = l_op-bukrs.

IF sy-subrc NE 0.

MESSAGE s022(e9) WITH 'T001' l_op-bukrs space space

RAISING error_message.

ENDIF.

APPEND l_op TO lt_op_one_contr.

    • Are there some items for furter processing ?

    • get VAT amount - field SBETW

PERFORM compute_tax USING lt_op_one_contr.

    • fill deregulation data

PERFORM fill_deregulation_fields USING lt_op_one_contr.

    • append down-payment request of contract into CA down-paym.collection

APPEND LINES OF lt_op_one_contr TO lt_op.

REFRESH lt_op_one_contr.

SELECT SINGLE fun01 INTO lw_zroisu002-hkont

FROM tfk033d

WHERE applk = 'R'

AND buber = 'R001'

AND ktopl = 'GAZ'

AND key01 = lt_contrcl-bukrs

  • AND key02 = lt_contrcl-sparte

AND key03 = lt_contrcl-kofiz

AND key04 = lw_zroisu002-hvorg

AND key05 = lw_zroisu002-tvorg.

CHECK sy-subrc = 0.

    • create new FI-CA document if there are some items in LT_OP

IF NOT lt_op[] IS INITIAL.

  • fill header FKKKO

y_vkk_doc_new-fkkko-applk = co_applk_isu. "'R'.

y_vkk_doc_new-fkkko-blart = lw_zroisu002-blart.

y_vkk_doc_new-fkkko-herkf = 'R4'. "Herkunft invoicing

y_vkk_doc_new-fkkko-ernam = sy-uname.

y_vkk_doc_new-fkkko-cpudt = sy-datum.

y_vkk_doc_new-fkkko-cputm = sy-uzeit.

y_vkk_doc_new-fkkko-bldat = x_bldat.

y_vkk_doc_new-fkkko-budat = x_budat.

y_vkk_doc_new-fkkko-waers = l_waers. "Waehrung des letzte Vertrags

lw_fkkopk-opupk = '1'.

lw_fkkopk-bukrs = '1930'.

lw_fkkopk-hkont = lw_zroisu002-hkont.

lw_fkkopk-betrh = l_nettobtr.

lw_fkkopk-betrw = l_nettobtr.

APPEND LINES OF lt_op TO y_vkk_doc_new-n_fkkop.

APPEND lw_fkkopk TO y_vkk_doc_new-n_fkkopk.

ENDIF.

ENDFUNCTION.

0 Kudos

You are using the flat export structure <b>y_vkk_doc_new</b> to create a new line.

I have tried that before, and it all works pretty good. But:

As I stated in the original post, I am not allowed to use the structure Y_VKK_DOC_NEW to create a new line. There are different processes that use that user-exit in a shared function module. If I use the flat structure, then no one else would be allowed to use it or I would overwrite something.

So is there any way to create a new line, by appending to the tables parameter T_VKK_DOC_ID ?

0 Kudos

No..Its not possible.

Thanks,

Durgesh.

0 Kudos

Hi Daniel,

I tried your piece of code but I am getting error as "G/L account 1018 14100000 cannot be posted to, please correct your entry"

marcushautz
Explorer
0 Kudos

Thanks. I'll find an alternative.