Creazione Batch Input per transaz. ABUMN
Per acquisire un movimento cespite: Giroconto interno a sociètà
*&---------------------------------------------------------------------**& Report ZF15_AA_GIROCONTO_STOCK
*&
*&---------------------------------------------------------------------*
*& SUPERATO ANCHE IL PROBLEMA CHE IN BACKGROUND SI VERIFICAVA
*& IL SEGUENTE
*& ERRORE “Dati Batch-Input per dynpro SAPLSPO4 0300 inesistenti”
*& SETTANDO PRIMA DI RICHIMARE IL BATCH INPUT il SET ID 'BUK' INSERENDO
*& IL NOME DELLA SOCIETA'
*&---------------------------------------------------------------------*
REPORT zf15_aa_giroconto_stock LINE-SIZE 181.
*======================================================================*
* INCLUDES *
*======================================================================*
*&---------------------------------------------------------------------*
*& Include ZF15_AA_GIROCONTO_STOCK_TOP
*&---------------------------------------------------------------------*
*======================================================================*
* TABLES *
*======================================================================*
TABLES: zf15_aa_girstock.
*======================================================================*
* TYPES
*======================================================================*
TYPES: BEGIN OF ty_output.
INCLUDE STRUCTURE zf15_aa_girstock.
TYPES: type TYPE c LENGTH 2,
END OF ty_output,
tt_cespiti TYPE zf15_aa_girstock.
*======================================================================*
* GLOBAL TABLES *
*======================================================================*
DATA: gt_cespiti TYPE TABLE OF zf15_aa_girstock,
gt_output TYPE TABLE OF ty_output.
*======================================================================*
* CONSTANTS *
*======================================================================*
CONSTANTS: gc_x TYPE char1 VALUE 'X',
gc_societa TYPE char3 VALUE 'AAA', "Nome società
gc_ok TYPE char3 VALUE 'SI',
gc_ko TYPE char3 VALUE 'NO'.
*======================================================================*
* GLOBAL DATA *
*======================================================================*
DATA: gv_error TYPE c LENGTH 1,
gv_sydatum TYPE c LENGTH 10,
gv_tot TYPE i,
ls_output TYPE ty_output.
FIELD-SYMBOLS: <fs> TYPE zf15_aa_girstock.
*======================================================================*
* ALV GRID *
*======================================================================*
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_layout TYPE slis_layout_alv.
*======================================================================*
* BATCH DATA *
*======================================================================*
DATA: BEGIN OF bdcdata OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdcdata.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& Include ZF15_AA_GIROCONTO_STOCK_SEL
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-s01.
SELECT-OPTIONS: so_anln1 FOR zf15_aa_girstock-anln1.
PARAMETERS: p_elab TYPE zstato_elab DEFAULT 'E' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK 1.
PARAMETERS: p_mode TYPE mode DEFAULT 'N' OBLIGATORY.
*&---------------------------------------------------------------------*
*& Include ZF15_AA_GIROCONTO_STOCK_FORM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form ESTRAI_DATI
*&---------------------------------------------------------------------*
* Estrazione cespiti da girocontare
*----------------------------------------------------------------------*
FORM estrai_dati .
REFRESH gt_cespiti.
SELECT * FROM zf15_aa_girstock INTO TABLE gt_cespiti
WHERE anln1 IN so_anln1
AND elabor_scarto EQ p_elab.
IF gt_cespiti[] IS INITIAL.
gv_error = '1'. " Nessun dato estratto
ENDIF.
ENDFORM. " ESTRAI_DATI
*&---------------------------------------------------------------------*
*& Form GIROCONTO
*&---------------------------------------------------------------------*
* Per tutti i cespiti estratti viene effettuato il giroconto
*----------------------------------------------------------------------*
FORM giroconto .
DATA: lv_subrc LIKE sy-subrc.
CHECK gv_error IS INITIAL.
LOOP AT gt_cespiti ASSIGNING <fs>.
CLEAR lv_subrc.
PERFORM call_abumn USING <fs> CHANGING lv_subrc <fs>-msgtxt.
IF lv_subrc = 0.
DELETE zf15_aa_girstock FROM <fs>.
COMMIT WORK.
ELSE.
<fs>-elabor_scarto = 'S'.
MODIFY zf15_aa_girstock FROM <fs>.
COMMIT WORK.
ENDIF.
ENDLOOP.
ENDFORM. " GIROCONTO
*&---------------------------------------------------------------------*
*& Form CALL_ABUMN
*&---------------------------------------------------------------------*
* Call transaction ABUMN
*----------------------------------------------------------------------*
FORM call_abumn USING is_data TYPE tt_cespiti
CHANGING e_subrc LIKE sy-subrc
e_msgtxt TYPE msgtxt.
CLEAR e_subrc.
DATA: x_options TYPE ctu_params,
lv_data_term TYPE c LENGTH 10,
lv_belnr TYPE bkpf-belnr,
lv_beg_next_month TYPE datum,
* beg ins 23.12.2015
lv_bukrs TYPE bukrs,
* end ins 23.12.2015
* beg del 22.12.2015
* lv_bnmonth_c TYPE c LENGTH 10,
* end del 22.12.2015
ls_anep TYPE anep.
CLEAR x_options.
CLEAR: bdcdata, messtab, e_subrc, lv_data_term.
REFRESH: bdcdata, messtab.
x_options-dismode = p_mode.
x_options-updmode = 'S'.
x_options-cattmode = ' '.
x_options-defsize = ' '.
x_options-racommit = 'X'.
x_options-nobinpt = ' '.
x_options-nobiend = ' '.
CONCATENATE is_data-term_date+6(2)
is_data-term_date+4(2)
is_data-term_date+0(4)
INTO lv_data_term SEPARATED BY '.'.
*beg del 22.12.2015 - La data di riferimento per la registrazione
*del giroconto deve corrispondere alla data di termination
**************************************************************
* " data riferimento deve essere il primo gg del mese
* " successivo alda data di termination (date_start_invoice)
* " calcolo prima l'ultimo giorno del mese di termination,
* CALL FUNCTION 'LAST_DAY_OF_MONTHS'
* EXPORTING
* day_in = is_data-term_date
* IMPORTING
* last_day_of_month = lv_beg_next_month.
* " giorno successivo a fine mese termination
* " corrisponde a inizio mese successivo.
* lv_beg_next_month = lv_beg_next_month + 1.
* CONCATENATE lv_beg_next_month+6(2)
* lv_beg_next_month+4(2)
* lv_beg_next_month+0(4)
* INTO lv_bnmonth_c SEPARATED BY '.'.
**************************************************************
* end del 22.12.2015
* beg ins 23.12.2015
CLEAR lv_bukrs.
GET PARAMETER ID 'BUK' FIELD lv_bukrs.
IF lv_bukrs IS INITIAL.
SET PARAMETER ID 'BUK' FIELD 'AAA'. "Nome società
ENDIF.
* end ins 23.12.2015
PERFORM bdc_dynpro USING 'SAPLAMDP' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE' '=SAVE'.
PERFORM bdc_field USING 'RAIFP2-ANLN1' is_data-anln1.
PERFORM bdc_field USING 'RAIFP2-ANLN2' is_data-anln2.
PERFORM bdc_field USING 'RAIFP1-BLDAT' lv_data_term. "data termin
PERFORM bdc_field USING 'RAIFP1-BUDAT' gv_sydatum.
* beg mod 22.12.2015
* PERFORM bdc_field USING 'RAIFP1-BZDAT' lv_bnmonth_c."inizio mm succ
PERFORM bdc_field USING 'RAIFP1-BZDAT' lv_data_term. "data termin
* end mod 22.12.2015
PERFORM bdc_field USING 'RAIFP3-XBANL' 'X'.
PERFORM bdc_field USING 'RAIFP3-ANLN1' is_data-anln1_stock.
CALL TRANSACTION 'ABUMN' USING bdcdata
OPTIONS FROM x_options
MESSAGES INTO messtab.
CLEAR ls_anep.
WAIT UP TO 1 SECONDS.
SELECT SINGLE * FROM anep INTO ls_anep
WHERE bukrs = gc_societa
AND anln1 = is_data-anln1
AND anln2 = is_data-anln2
* beg mod 22.12.2015
* AND bzdat = lv_bnmonth_c
AND bzdat = is_data-term_date
* end mod 22.12.2015
AND ( bwasl = '320' OR " anno in corso
bwasl = '300' ). " anno precedente
DELETE messtab WHERE msgid = '15' AND msgnr = '239'.
DELETE messtab WHERE msgid = '00' AND msgnr = '352'.
IF messtab IS INITIAL AND ls_anep IS NOT INITIAL.
CLEAR ls_output.
MOVE-CORRESPONDING is_data TO ls_output.
ls_output-type = gc_ok.
ls_output-msgtxt = text-cre.
APPEND ls_output TO gt_output.
ELSE.
e_subrc = 4.
LOOP AT messtab.
CLEAR ls_output.
MOVE-CORRESPONDING is_data TO ls_output.
ls_output-type = messtab-msgtyp.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = messtab-msgid
lang = sy-langu
no = messtab-msgnr
v1 = messtab-msgv1
v2 = messtab-msgv2
v3 = messtab-msgv3
v4 = messtab-msgv4
IMPORTING
msg = ls_output-msgtxt.
AT FIRST.
e_msgtxt = ls_output-msgtxt.
ENDAT.
APPEND ls_output TO gt_output.
ENDLOOP .
ENDIF.
ENDFORM. " CALL_ABUMN
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form DISPLAY_OUTPUT
*&---------------------------------------------------------------------*
* Visualizazzione lista ALV
*----------------------------------------------------------------------*
FORM display_output .
DATA: lv_repid LIKE sy-repid.
PERFORM: create_layout,
create_fieldcat.
lv_repid = sy-repid.
IF sy-batch IS INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_bypassing_buffer = 'X'
i_callback_program = lv_repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat
TABLES
t_outtab = gt_output.
ELSE.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_bypassing_buffer = 'X'
i_callback_program = lv_repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat
TABLES
t_outtab = gt_output.
ENDIF.
ENDFORM. " DISPLAY_OUTPUT
*&---------------------------------------------------------------------*
*& Form CREATE_FIELDCAT
*&---------------------------------------------------------------------*
* Definizione colonne nella lista ALV
*----------------------------------------------------------------------*
FORM create_fieldcat .
DATA: ls_fieldcat LIKE LINE OF gt_fieldcat.
CLEAR gt_fieldcat.
REFRESH: gt_fieldcat.
*
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = 'ZF15_AA_GIRSTOCK'
CHANGING
ct_fieldcat = gt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'TYPE'.
ls_fieldcat-col_pos = 0.
ls_fieldcat-outputlen = 5.
INSERT ls_fieldcat INTO gt_fieldcat INDEX 1.
ENDFORM. " CREATE_FIELDCAT
*&---------------------------------------------------------------------*
*& Form CREATE_LAYOUT
*&---------------------------------------------------------------------*
FORM create_layout .
CLEAR gs_layout.
gs_layout-colwidth_optimize = gc_x.
ENDFORM. " CREATE_LAYOUT
*======================================================================*
* INITIALIZATION.
*======================================================================*
INITIALIZATION.
CONCATENATE sy-datum+6(2)
sy-datum+4(2)
sy-datum+0(4)
INTO gv_sydatum SEPARATED BY '.'.
*======================================================================*
* START-OF-SELECTION *
*======================================================================*
START-OF-SELECTION.
PERFORM estrai_dati.
PERFORM giroconto.
*======================================================================*
* END-OF-SELECTION *
*======================================================================*
END-OF-SELECTION.
IF gv_error IS INITIAL.
PERFORM display_output.
ELSE.
CASE gv_error.
WHEN '1'. " Nessun dato estratto
MESSAGE text-e01 TYPE 'S' DISPLAY LIKE 'E'.
ENDCASE.
ENDIF.
EBOOK: le mie guide sono visualizzabili cliccando sui link:
1. SAP EWM (Extended Warehouse Management)
3. SAP VIM (Vendor Invoice Management)
1. SAP EWM (Extended Warehouse Management)
3. SAP VIM (Vendor Invoice Management)
SE MI CONTATTATE IN PRIVATO, PAGATE LA META' DEL PREZZO DI AMAZON, E POTETE SCEGLIERE IL FORMATO WORD o PDF.
>>> RECENSIONI DEI LIBRI su Amazon Kindle <<<
Ebook: SAP CDS: https://www.amazon.it/dp/B0B9BD1RN3#customerReviews
Ebook: SAP MM: https://www.amazon.it/dp/B0C3MKD9BR#customerReviews
Ebook: SAP MII: https://www.amazon.it/dp/B0C4392MY9#customerReviews
Ebook: SAP VIM: https://www.amazon.it/dp/B0C6FBK8QN#customerReviews
Ebook: SAP MM: https://www.amazon.it/dp/B0C3MKD9BR#customerReviews
Ebook: SAP MII: https://www.amazon.it/dp/B0C4392MY9#customerReviews
Ebook: SAP VIM: https://www.amazon.it/dp/B0C6FBK8QN#customerReviews
Ebook: SAP EWM: https://www.amazon.it/dp/B0CL6TXP1V#customerReviews
Nessun commento:
Posta un commento