Вы находитесь на странице: 1из 4

Genereren idocs invoices history (transacite ZIDOCINVOICE

Voorwaarde: gekozen message moet ingericht zijn in customizing.

Creert idoc + record in NAST + ALV output met resultaat:

*&---------------------------------------------------------------------*
*& Report Z_IDOCS_INVOIC_HISTORY
*&
*&---------------------------------------------------------------------*
*Myuice/CTac Dynamics
*Jeannette van Kranenburg
*december 2009

*Purpose:

*this report creates for already posted invoices, an invoic-idoc (INVOIC02)


*(customizing message-control and partnerprofiles etc.must be implemented)
*for invoices till a certain date and which have FKSTO = ''.
*this is for legacy data for the CRM system
**************************************************************************
*changes: (please report to: jeannette.van.kranenburg@muice.nl
*date User Purpose
*
*&---------------------------------------------------------------------*

REPORT z_idocs_invoic_history.

PARAMETERS: p_fkdat TYPE fkdat,


p_kschl TYPE kschl DEFAULT 'ZBAA'.

SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.


PARAMETERS: p_bukrs TYPE t001-bukrs DEFAULT '0010'.
PARAMETERS: p_vkorg TYPE vkorg DEFAULT '0010'.
PARAMETERS: p_vtweg TYPE vtweg DEFAULT '10' .
PARAMETERS: p_spart TYPE spart DEFAULT '10' .
*p_kokrs "controlling area nog toevoegen?
SELECTION-SCREEN: END OF BLOCK blk1.

TABLES: nast. " is noodzakelijk anders is nast leeg in program RSNASTED


DATA: ta_nast TYPE STANDARD TABLE OF nast.
DATA: wa_nast TYPE nast.
DATA: ta_vbrk TYPE STANDARD TABLE OF vbrk.
DATA: wa_vbrk TYPE vbrk.
DATA: us_screen TYPE max_severity,
return TYPE sy-subrc.
TYPES: BEGIN OF ty_itab,
vbeln TYPE vbeln,
vstat TYPE string.
TYPES: END OF ty_itab.

DATA: itab TYPE STANDARD TABLE OF ty_itab.


DATA: wa_itab TYPE ty_itab.

DATA: rf_alv TYPE REF TO cl_salv_table.

*---------------------------------------------------------------
START-OF-SELECTION.
*---------------------------------------------------------------
refresh itab.
clear wa_itab.

SELECT * FROM vbrk INTO TABLE ta_vbrk WHERE fkart = 'F2'


AND fkdat <= p_fkdat
AND vkorg = p_vkorg
AND vtweg = p_vtweg
AND spart = p_spart
AND bukrs = p_bukrs
AND fksto = ''.

*---------------------------------------------------------------
END-OF-SELECTION.
*---------------------------------------------------------------
wa_nast-mandt = sy-mandt.
wa_nast-kappl = 'V3'.
wa_nast-kschl = p_kschl.
wa_nast-spras = 'E'.
wa_nast-parnr = 'RFC_DYNCRM'.
wa_nast-parvw = 'LS'.
wa_nast-erdat = sy-datum.
wa_nast-eruhr = sy-uzeit.
wa_nast-nacha = 'A'.
wa_nast-vsztp = '1'. " 3 and 4 ignored by rsnasted
wa_nast-datvr = sy-datum.
wa_nast-uhrvr = sy-uzeit.
wa_nast-usnam = sy-uname.
wa_nast-vstat = 0.
wa_nast-nauto = 'X'.
wa_nast-tdarmod = '1'.
wa_nast-objtype = 'VBRK'.
wa_nast-anzal = 1.
wa_nast-manue = 'X'.

break jkrane.

LOOP AT ta_vbrk INTO wa_vbrk.


clear: wa_itab, return.
wa_nast-objky = wa_vbrk-vbeln.
APPEND wa_nast TO ta_nast.
INSERT nast FROM wa_nast.
COMMIT WORK.

SELECT SINGLE * FROM nast WHERE objky = wa_vbrk-vbeln AND


kschl = p_kschl AND vsztp = '1'
and erdat = sy-datum
and vstat = 0.

*zonder melding
if sy-subrc = 0.

PERFORM einzelnachricht IN PROGRAM rsnast00 USING return .


"met melding per message: gebruik:
"PERFORM edi_processing IN PROGRAM rsnasted using us_screen
" return.

IF return = 0.
wa_itab-vbeln = wa_vbrk-vbeln.
wa_itab-vstat = 'Succes'.
APPEND wa_itab TO itab.
ELSE.
wa_itab-vbeln = wa_vbrk-vbeln.
wa_itab-vstat = 'error'.
APPEND wa_itab TO itab.

ENDIF.

endif.

ENDLOOP.

cl_salv_table=>factory( IMPORTING r_salv_table = rf_alv


CHANGING t_table = itab ).
rf_alv->display( ).