‎2006 Dec 19 10:23 AM
Hi all,
this simply program goes to dump when you sum the colums "menge" in ALV-grid. Why? I don't understant! Help me please. You can cut&paste the code and try it on your server..
REPORT ztempi_oda.
TYPE-POOLS slis.
tipo record da visualizzare
TYPES: BEGIN OF t_record,
ekorg LIKE eban-ekorg,
werks LIKE eban-werks,
badat LIKE eban-badat,
banfn LIKE eban-banfn,
banpr LIKE eban-banpr,
afnam LIKE eban-afnam,
erdat LIKE eban-erdat,
bedat LIKE ekko-bedat,
ebeln LIKE ekpo-ebeln,
ekgrp LIKE ekko-ekgrp,
lifnr LIKE ekko-lifnr,
name1 LIKE lfa1-name1,
konnr LIKE ekpo-konnr,
trrda TYPE i,
terda TYPE i,
END OF t_record.
tabelle in questione
TABLES: eban, ekpo, ekko, lfa1.
tabelle interne
DATA: wa_record TYPE t_record,
it_record TYPE STANDARD TABLE OF t_record.
*ALV data declarations
DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
wa_fieldcatalog LIKE LINE OF it_fieldcatalog,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
selezioni dell'utente
SELECT-OPTIONS: s_ekorg FOR eban-ekorg,
s_werks FOR eban-werks,
s_badat FOR eban-badat,
s_banpr FOR eban-banpr,
s_afnam FOR eban-afnam,
s_ekgrp FOR eban-ekgrp.
************************************************************************
START OF SELECTION *
************************************************************************
START-OF-SELECTION.
carico i dati richiesti
PERFORM load_report.
stampo i dati
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
&----
*& Form load_report
&----
text
----
--> p1 text
<-- p2 text
----
FORM load_report.
DATA: temp_bedat LIKE ekko-aedat,
differenza LIKE wa_record-trrda,
banfn_old LIKE eban-banfn,
ebeln_old LIKE ekpo-ebeln.
pulisco la tabella interna
CLEAR: it_record, wa_record.
CLEAR banfn_old.
scorro tutte le righe di tutti gli rda
SELECT *
FROM eban
WHERE ekorg IN s_ekorg AND
werks IN s_werks AND
badat IN s_badat AND
banpr IN s_banpr AND
afnam IN s_afnam AND
ekgrp IN s_ekgrp AND
loekz NE 'X'
ORDER BY banfn.
considero solo una riga per ogni RDA
IF eban-banfn NE banfn_old.
assegnazione dei valori della riga
wa_record-ekorg = eban-ekorg.
wa_record-werks = eban-werks.
wa_record-badat = eban-badat.
wa_record-banfn = eban-banfn.
wa_record-banpr = eban-banpr.
wa_record-afnam = eban-afnam.
wa_record-erdat = eban-erdat.
CLEAR ebeln_old.
scorro tutte le righe degli ODA corrispondenti a quel RDA
SELECT *
FROM ekpo
WHERE banfn EQ eban-banfn AND
loekz NE 'X'
ORDER BY ebeln.
considero solo le righe con ODA diverso
IF ekpo-ebeln NE ebeln_old.
wa_record-ebeln = ekpo-ebeln.
wa_record-konnr = ekpo-konnr.
aggiornamento per evitare le posizioni in ekpo
ebeln_old = ekpo-ebeln.
mi attacco codice fornitore effettivo e buyer
SELECT SINGLE ekgrp lifnr bedat
INTO (wa_record-ekgrp ,wa_record-lifnr, wa_record-bedat)
FROM ekko
WHERE ebeln EQ wa_record-ebeln.
calcolo delle differenze di data
PERFORM calcola_differenze
USING wa_record-erdat wa_record-badat wa_record-trrda.
PERFORM calcola_differenze
USING wa_record-bedat wa_record-erdat wa_record-terda.
mi attacco descrizione del fornitore
SELECT SINGLE name1
INTO wa_record-name1
FROM lfa1
WHERE lifnr = wa_record-lifnr.
popolo la tabella interna
APPEND wa_record TO it_record.
ENDIF.
ENDSELECT.
aggiornamento per evitare le posizioni in eban
banfn_old = wa_record-banfn.
pulizia wa prima di nuovo RDA
CLEAR wa_record.
ENDIF.
ENDSELECT.
ENDFORM. " load_report
&----
*& Form build_fieldcatalog
&----
Routine per la generazione dei campi della ALV GRID
----
No parameters
----
FORM build_fieldcatalog .
wa_fieldcatalog-fieldname = 'EKORG'.
wa_fieldcatalog-seltext_m = 'Org.Acq.'.
wa_fieldcatalog-col_pos = 19.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'WERKS'.
wa_fieldcatalog-seltext_m = 'Divisione'.
wa_fieldcatalog-col_pos = 20.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BADAT'.
wa_fieldcatalog-seltext_m = 'Data RDA'.
wa_fieldcatalog-col_pos = 2.
wa_fieldcatalog-emphasize = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BANFN'.
wa_fieldcatalog-seltext_m = 'Num.RDA'.
wa_fieldcatalog-col_pos = 3.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BANPR'.
wa_fieldcatalog-seltext_m = 'St.ril.'.
wa_fieldcatalog-col_pos = 5.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'AFNAM'.
wa_fieldcatalog-seltext_m = 'Richiedente'.
wa_fieldcatalog-col_pos = 6.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'ERDAT'.
wa_fieldcatalog-seltext_m = 'Data rilascio'.
wa_fieldcatalog-col_pos = 7.
wa_fieldcatalog-emphasize = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BEDAT'.
wa_fieldcatalog-seltext_m = 'Data ODA'.
wa_fieldcatalog-col_pos = 8.
wa_fieldcatalog-emphasize = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'EBELN'.
wa_fieldcatalog-seltext_m = 'Num.ODA'.
wa_fieldcatalog-col_pos = 9.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'EKGRP'.
wa_fieldcatalog-seltext_m = 'Buyer'.
wa_fieldcatalog-col_pos = 11.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'LIFNR'.
wa_fieldcatalog-seltext_m = 'Forn.ord.'.
wa_fieldcatalog-col_pos = 14.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NAME1'.
wa_fieldcatalog-seltext_m = 'Descr.'.
wa_fieldcatalog-col_pos = 15.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'KONNR'.
wa_fieldcatalog-seltext_m = 'Cont.rif.'.
wa_fieldcatalog-col_pos = 16.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'TRRDA'.
wa_fieldcatalog-seltext_m = 'Tempo.ril.(gg)'.
wa_fieldcatalog-col_pos = 17.
wa_fieldcatalog-key = 'X'.
fa la media di questo valore e la visualizza alla fine dell'ALV
wa_fieldcatalog-do_sum = 'C'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'TERDA'.
wa_fieldcatalog-seltext_m = 'Tempo elab.(gg)'.
wa_fieldcatalog-col_pos = 18.
wa_fieldcatalog-key = 'X'.
fa la media di questo valore e la visualizza alla fine dell'ALV
wa_fieldcatalog-do_sum = 'C'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
ENDFORM. " fill_fieldcatalog
&----
*& Form build_layout
&----
Routine per il settaggio del layout della ALV GRID
----
No parameters
----
FORM build_layout .
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = ''.
ENDFORM. " build_layout
&----
*& Form DISPLAY_ALV_REPORT
&----
Routine per la visualizzazione della ALV GRID
----
No parameters
----
FORM display_alv_report .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = it_fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_record
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
&----
*& Form calcola_differenze
&----
text
----
-->P_D1 text
-->P_D2 text
-->P_DIFF text
----
FORM calcola_differenze USING p_d1
p_d2
p_diff.
DATA: a(1) TYPE c,
data1 like sy-datum,
data2 like sy-datum.
p_diff = 0.
data1 = p_d1.
data2 = p_d2.
IF data1 < data2.
p_diff = -1.
ELSE.
WHILE data2 < data1.
CLEAR a.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = data2
factory_calendar_id = 'IT'
IMPORTING
workingday_indicator = a.
IF a IS INITIAL.
p_diff = p_diff + 1.
ENDIF.
data2 = data2 + 1.
ENDWHILE.
ENDIF.
ENDFORM. " calcola_differenze
‎2006 Dec 19 10:25 AM
‎2006 Dec 19 10:29 AM
If I insert
wa_fieldcatalog-do_sum = 'C'.
the program goes immediatly in dump.
if i don't have
wa_fieldcatalog-do_sum = 'C'.
the program view the alv.grid correctly but goes in dump when I push "sum" button
Why?
‎2006 Dec 19 10:26 AM
Hi,
MENGE is quantity field. You need to map with UNIT field.
Regards
Bhupal Reddy
‎2006 Dec 19 10:29 AM
we r not getting dump for this program...there is no MENGe field in the prog.
‎2006 Dec 19 10:29 AM
fcat1-fieldname = 'PGMNG'.
fcat1-key = ''.
fcat1-outputlen = '13'.
fcat1-just = 'R'.
fcat1-seltext_m = 'PL.QTY.'.
fcat1-ddictxt = 'M'.
fcat1-inttype = 'P'.
fcat1-datatype = 'QUAN'.
fcat1-no_zero = 'X'.
fcat1-do_sum = 'X'.
append fcat1.
clear fcat1.
‎2006 Dec 19 10:32 AM
‎2006 Dec 19 10:31 AM
Hi Gilbert,
This code is working absolutely fine,
check the parameters you are passing in selection-screen.
Regards,
pankaj singh
‎2006 Dec 19 10:33 AM
Yes, it works, but if tou sum the last column it goes in dump....or not?
‎2006 Dec 19 10:35 AM
Hi,
last column is divison that is a character field
befor that tempo elob is there..and i can very well click on sum and see at the end..
its 52.
regards,
pankaj singh
‎2006 Dec 19 10:35 AM
Now I try to insert the unit of mesurament and sum the menge for each UOM...
‎2006 Dec 19 10:43 AM
sorry. The code I insert is the correctly code of another program.
This is the right code that foes in dump.
REPORT zanalisi_oda .
TYPE-POOLS slis.
tipo record da visualizzare
TYPES: BEGIN OF t_record,
aedat LIKE ekpo-aedat,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
txz01 LIKE ekpo-txz01,
werks LIKE ekpo-werks,
knttp LIKE ekpo-knttp,
menge LIKE ekpo-menge,
END OF t_record.
tabelle in questione
TABLES: ekpo.
tabelle interne
DATA: wa_record TYPE t_record,
it_record TYPE STANDARD TABLE OF t_record.
*ALV data declarations
DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
wa_fieldcatalog LIKE LINE OF it_fieldcatalog,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
selezioni dell'utente
SELECT-OPTIONS: s_aedat FOR ekpo-aedat,
s_ebeln FOR ekpo-ebeln,
s_matnr FOR ekpo-matnr,
s_werks FOR ekpo-werks.
PARAMETERS: c_elikz AS CHECKBOX DEFAULT 'X'.
************************************************************************
START OF SELECTION *
************************************************************************
START-OF-SELECTION.
carico i dati richiesti
PERFORM load_report.
stampo i dati
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
&----
*& Form load_report
&----
text
----
--> p1 text
<-- p2 text
----
FORM load_report .
CLEAR it_record.
*ciclo nella tabella EKPO
SELECT *
FROM ekpo
WHERE aedat IN s_aedat AND
ebeln IN s_ebeln AND
matnr IN s_matnr AND
werks IN s_werks AND
elikz EQ c_elikz AND
loekz NE 'X'
ORDER BY ebeln ebelp.
CLEAR wa_record.
wa_record-aedat = ekpo-aedat.
wa_record-ebeln = ekpo-ebeln.
wa_record-ebelp = ekpo-ebelp.
wa_record-matnr = ekpo-matnr.
wa_record-txz01 = ekpo-txz01.
wa_record-werks = ekpo-werks.
wa_record-knttp = ekpo-knttp.
wa_record-menge = ekpo-menge.
APPEND wa_record TO it_record.
ENDSELECT.
ENDFORM. " load_report
&----
*& Form build_fieldcatalog
&----
Routine per la generazione dei campi della ALV GRID
----
No parameters
----
FORM build_fieldcatalog .
wa_fieldcatalog-fieldname = 'AEDAT'.
wa_fieldcatalog-seltext_m = 'Data ODA'.
wa_fieldcatalog-col_pos = 0.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'EBELN'.
wa_fieldcatalog-seltext_m = 'Numero ODA'.
wa_fieldcatalog-col_pos = 1.
wa_fieldcatalog-key = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'EBELP'.
wa_fieldcatalog-seltext_m = 'Pos.ODA'.
wa_fieldcatalog-col_pos = 2.
wa_fieldcatalog-key = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'MATNR'.
wa_fieldcatalog-seltext_m = 'Materiale'.
wa_fieldcatalog-col_pos = 3.
wa_fieldcatalog-emphasize = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'TXZ01'.
wa_fieldcatalog-seltext_m = 'Descrizione'.
wa_fieldcatalog-col_pos = 4.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'WERKS'.
wa_fieldcatalog-seltext_m = 'Mag.'.
wa_fieldcatalog-col_pos = 5.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'KNTTP'.
wa_fieldcatalog-seltext_m = 'Tipo contab.'.
wa_fieldcatalog-col_pos = 6.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'KOSTL'.
wa_fieldcatalog-seltext_m = 'CdC'.
wa_fieldcatalog-col_pos = 7.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'EIND'.
wa_fieldcatalog-seltext_m = 'Data cons.prev.'.
wa_fieldcatalog-col_pos = 8.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'MENGE'.
wa_fieldcatalog-seltext_m = 'Qta ord.'.
wa_fieldcatalog-col_pos = 9.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
ENDFORM. " fill_fieldcatalog
&----
*& Form build_layout
&----
Routine per il settaggio del layout della ALV GRID
----
No parameters
----
FORM build_layout .
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = ''.
ENDFORM. " build_layout
&----
*& Form DISPLAY_ALV_REPORT
&----
Routine per la visualizzazione della ALV GRID
----
No parameters
----
FORM display_alv_report .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = it_fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_record
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
‎2006 Dec 19 10:53 AM
‎2006 Dec 19 10:56 AM
This is only a little view of the report. At the end the tables and the fields used are much more...
I don't understand the dump! I try a lot of solution...but nothing...