ALV REPORT TO BW, without extraction???
Hello!
Can I execute a ALV report (from SAP) in BW, without extraction, at the same time able to use all Bex functions??? is it possible??? I think not, but, somebody can tell me what you think....
Thanks
I have some reports in R/3, create them with ALV, function module that select data from different tables based in a lot of conditions... the client wants to load this ALV reports to BW, but these display is not keept in any table in R/3, is execution "online" .... therefore, the virtual cube is an option, however I dont know if it is possible to give all variables entry, and in base this conditions execcute de report in BEx....
If you have documentation, or if you need additional information for helping me tellme and I will give you my e-mail....
thanks a lot... it is so urgently for me...
Similar Messages
-
Run alv report without selection screen in background
Hello Every body,
i programmed a ALV Report without selection screen, and i want to create a job for this alv report.
Any help?
Thank u.
Ouail.Hi Steve,
Can you tell me where i have to put your code?
this is my abap code:
START-OF-SELECTION.
p_filref = '\\SAPSERVER\f\SAFT\ivat\FI_Extract_1000_20140709_102346_910.XML'.
PERFORM copy_from_xml_to_itab TABLES it_ref_file
ref_xml_data
USING p_filref.
**Begin Extraction File
SUBMIT ZZ_FI_IVAT_EXTRACTOR
WITH p_bukrs EQ '1000'
WITH p_gjahr EQ '1998'
WITH filepath EQ '\\SAPSERVER\f\SAFT\iVAT_Extractie\'
WITH cldata eq space
AND RETURN.
DATA: FILE_TABLE TYPE TABLE OF SDOKPATH,
DIR_TABLE TYPE TABLE OF SDOKPATH.
CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
DIRECTORY = '\\SAPSERVER\f\SAFT\iVAT_Extractie\'
FILTER = '*.*'
TABLES
FILE_TABLE = FILE_TABLE
DIR_TABLE = DIR_TABLE
EXCEPTIONS
CNTL_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.
"get file name
LOOP AT FILE_TABLE INTO p_filref.
ENDLOOP.
CONCATENATE '\\SAPSERVER\f\SAFT\iVAT_Extractie\' p_filref INTO path.
PERFORM copy_from_xml_to_itab TABLES t_ext_file
ext_xml_data
USING path.
PERFORM fill_xml_tab_in .
perform build_fieldcatalog.
PERFORM compare_data_ref_ext.
PERFORM send_email.
perform display_alv_report.
PERFORM delete_extraction_file.
in the perform copy_from_xml_to_itab TABLES it_ref_file......, i use this code:
CREATE OBJECT gcl_xml.
*Upload XML File
CALL METHOD gcl_xml->import_from_file
EXPORTING
filename = p_filref
RECEIVING
retcode = gv_subrc.
IF gv_subrc = 0.
CALL METHOD gcl_xml->render_2_xstring
IMPORTING
retcode = gv_subrc
stream = gv_xml_string
size = gv_size.
IF gv_subrc = 0.
REFRESH gt_xml_data[].
* Convert XML to internal table
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = gv_xml_string
TABLES
xml_table = gt_xml_data
return = gt_return.
ENDIF.
ENDIF. -
How to extract the column width in ALv report if its executed in background
I am executing an ALV report in background , in front end i am getting data properly, in back end for some columns some of the digits are missing.For example if PO no is of 10 digits it will display only 8 becos column size is like that , how to extract coulmns in back ground.
I have executed in background and checked the spool and for some of the columns width is not sufficient to display comeplete data so please suggest how to extract the columns sizes if executed inj background for an ALVHi Deepthi,
you can try with the above mentioned suggestions ,if its worked its fine ,
If not use Docking container instead of custom container, For ALV in back ground jobs, its suggest to use docking container instead of custom container , below you can find the declaration for docking container and code to use docking and custom container in your program for fore and back ground.
or you can use docking container alone for both operations.
Data : G_DOCK1 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
IF CCON IS INITIAL. (ccon is container name )
*Check whether the program is run in batch or foreground
IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
*Run in foreground
CREATE OBJECT CCON
EXPORTING
CONTAINER_NAME = 'CON1'.
CREATE OBJECT GRID1
EXPORTING
I_PARENT = parent_1.
ELSE.
*Run in background
CREATE OBJECT GRID1
EXPORTING
I_PARENT = G_DOCK1.
ENDIF.
ENDIF.
B&R,
Saravana.S -
ALV Report In Background.. Generating same out put using ABAP Extracts
Hi
We are running ALV reports and generating out put in background using Extracts. We are having a discussion that SAP doesnt recommend to execute ALV reports using batch and generate report output , as it heavily load for spool ... we are coming across some problem when I analyze Sm37 ... I found an error " ABAP framework unable to initialize " .
I want an input/suggestion what you guys think about it?
Thanks in Advanced...
ByeNope... Were using some batch id which use to run background job, as I am also in SAP Security, I just verify it has all the security to run the report . As this report is running fine if we ran it other then batch id ... as before it was running fine .
Thanks
Message was edited by: Saquib Khan -
Regarding the Extract in alv report
Hi gurus,
please explain to me what is the Extract in ALV's.
i have an alv report in which they declaired avariable like disextract and assigned a radio button, if the radiobutton is check then the data is stored in extract.what is the use of the extract?Hi,
Please check below thread;
Extract from ALV List
Regards
Jana -
ALV report Object Oriented way without containers?
Hi guru
I was hearing that alv report using OO concept can be created only using containers... if we use containers can we run the job in background as its gui interfacing... is there a way to create using oo and with out containers. Thanks.Hi Raj,
you can also use the new ALV object model class cl_salv_table for this. Refer to program SALV_DEMO_TABLE_REAL_SIMPLE to see how easy you can create a full screen ALV without container. Internally the class uses the FM REUSE_ALV_GRID_DISPLAY.
Regards Rudi -
Download a ALV report without repetitive headers and footers.
Hi,
I have an ALV report with header and footer. When I download the report into excel, after every 30 (approx) records there is a header and a footer. But I do not need it.
I need header only once and footer only once in the excel sheet. Please let me know how to achieve it.
Thanks
KrishnaHi Manish,
if sy-pagno EQ 1 or sy-batch = 'X'.
Call the top-of-page event code.
endif.
I don't think it can work as it calls the top-of-page at each page in batch mode. Better code should be something like :
if sy-pagno EQ 1.
Call the top-of-page event code.
endif.
Note : for a generic solution, I think the page number is not automatically page number 1 (for example, if we use a cover page or have printed something else before). So we'd should better use a global variable (first_time) set to 'X' just before CALL FUNCTION 'REUSE_ALV_LIST...' :
IF first_time = 'X'.
Call the top-of-page event code.
CLEAR first_time.
ENDIF.
To All,
I really made a big confusion in my previous answers, which were in fact about column headings (how to print them only once). Sorry about that.
Sandra -
ALV report without using field catalogue manually
I am looking for alv report in which I will not create fieldcatalogue manually but pass the structure as it is and display the alv. Please provide me sample code.
Moderator message: Please do not use all upper case in the future.
Edited by: Thomas Zloch on Apr 1, 2010 12:31 PM - converted to lower caseUse the function module "REUSE_ALV_FIELDCATALOG_MERGE" to create the field catalog of all the fields in a structure
eg :
data : xfieldcat type slis_t_fieldcat_alv.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = <internal table structure>
i_bypassing_buffer = 'X'
i_buffer_active = ' '
changing
ct_fieldcat = xfieldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = xfieldcat[]
tables
t_outtab = <internal table>.
Regards
Vinod
Edited by: Vinod Kumar on Apr 1, 2010 3:45 PM -
Hi,
Please help with a solution:
my requirement is to add the following to an existing program.
i need to add 3 fields from a new table(a table which is not used in the program).
the fields are :
Vendor Part No. : Field ZWTYVND-Z_WTY_MAT_VPN
Mail To Vendor No.: Field ZWTYVND-Z_WTY_LIFNR_MAIL
Mail To Vendor Name: Field ZWTYVND-WTY_NAME1
here is the program code:
REPORT zwtyrep008
LINE-SIZE 500
MESSAGE-ID zpp02.
*& Report ZWTYREP008 *
*$*$----------------------------------------------------------------$*$*
*$*$---T A B L E S--------------------------------------------------$*$*
*$*$----------------------------------------------------------------$*$*
TABLES: wty_pnwtyh_dia, "
wty_pnwtyv_dia,
mara,
usr21,
pnwtyv,
adrp,
s084.
*$*$----------------------------------------------------------------$*$*
*$*$ CONSTANTS
*$*$----------------------------------------------------------------$*$*
CONSTANTS: true(1) VALUE 'X',
false(1) VALUE ' '.
CONSTANTS: c_year_low(4) VALUE '1960',
c_year_high(4) VALUE '9999',
c_zero LIKE wty_pvwty_dia-valiv VALUE '0.00',
c_claim_to_process TYPE i VALUE 3000.
CONSTANTS: c_save(1) VALUE 'U'.
*$*$----------------------------------------------------------------$*$*
*$*$ TYPES
*$*$----------------------------------------------------------------$*$*
TYPE-POOLS: slis, pwty.
TYPES: BEGIN OF lt_period,
year(4),
poper(2),
start TYPE d,
end TYPE d,
END OF lt_period.
TYPES: BEGIN OF tp_charac_value,
atwrt LIKE cawn-atwrt,
END OF tp_charac_value.
TYPES: BEGIN OF tp_submit_records,
header_guid LIKE wty_pnwtyv_dia-header_guid,
versn LIKE wty_pnwtyv_dia-versn,
prev_version LIKE wty_pnwtyv_dia-prev_version,
kateg LIKE wty_pnwtyv_dia-kateg,
aktiv LIKE wty_pnwtyv_dia-aktiv,
pnguid LIKE wty_pnwtyv_dia-pnguid,
knumv LIKE wty_pnwtyv_dia-knumv,
END OF tp_submit_records.
TYPES: BEGIN OF tp_cond_table,
kschl LIKE konv-kschl,
zaehk LIKE konv-zaehk,
kinak LIKE konv-kinak,
kbetr LIKE konv-kbetr,
END OF tp_cond_table.
*$*$----------------------------------------------------------------$*$*
*$*$---I N T E R N A L T A B L E S--------------------------------$*$*
*$*$----------------------------------------------------------------$*$*
* Report table to display with ALV
DATA: t_detail_info TYPE STANDARD TABLE OF zwty_claim_avg_rep_det
WITH HEADER LINE
INITIAL SIZE 0.
FIELD-SYMBOLS:<fs_detail_info> LIKE LINE OF t_detail_info.
DATA: t_summary_alv TYPE STANDARD TABLE OF zwty_claim_avg_rep_sum
WITH HEADER LINE
INITIAL SIZE 0.
FIELD-SYMBOLS:<fs_summary_alv> LIKE LINE OF t_summary_alv.
DATA: t_detail_alv TYPE STANDARD TABLE OF zwty_claim_avg_rep_det
WITH HEADER LINE
INITIAL SIZE 0.
FIELD-SYMBOLS:<fs_detail_alv> LIKE LINE OF t_detail_alv.
DATA: it_submit_records TYPE HASHED TABLE OF tp_submit_records
WITH UNIQUE KEY header_guid versn
WITH HEADER LINE
INITIAL SIZE 0.
FIELD-SYMBOLS: <fs_submit_rec_vs2> TYPE tp_submit_records.
DATA: it_period TYPE HASHED TABLE OF lt_period
WITH UNIQUE KEY year poper
WITH HEADER LINE
INITIAL SIZE 0.
FIELD-SYMBOLS: <fs_it_period> LIKE LINE OF it_period.
DATA: it_pvwty_dia_all TYPE wty_pvwty_dia_tab.
FIELD-SYMBOLS: <fs_pvwty_dia_es3> LIKE LINE OF it_pvwty_dia_all.
DATA: it_cond_table TYPE STANDARD TABLE OF tp_cond_table
WITH HEADER LINE
INITIAL SIZE 0.
FIELD-SYMBOLS: <fs_cond_table> TYPE tp_cond_table.
*$*$----------------------------------------------------------------$*$*
*$*$---G L O B A L D A T A ---------------------------------------$*$*
*$*$----------------------------------------------------------------$*$*
DATA: gt_fieldcat_sum TYPE slis_t_fieldcat_alv,
gt_fieldcat_det TYPE slis_t_fieldcat_alv,
gtw_fieldcat LIKE LINE OF gt_fieldcat_sum,
gt_top_of_page TYPE slis_t_listheader,
gtw_top_of_page LIKE LINE OF gt_top_of_page,
gt_end_of_page TYPE slis_t_listheader,
gtw_end_of_page LIKE LINE OF gt_end_of_page,
gs_layout TYPE slis_layout_alv,
gt_excluding TYPE slis_t_extab,
gtw_excluding LIKE LINE OF gt_excluding,
gs_variant1 TYPE disvariant,
gs_variant2 TYPE disvariant,
eventcat TYPE slis_t_event, "EVENEMENT
eventcat_ln LIKE LINE OF eventcat, "LIGNE D'EVENEMENT
gt_sort TYPE slis_t_sortinfo_alv,
gtw_sort LIKE LINE OF gt_sort.
DATA: wa_lis_progname LIKE sy-cprog,
wa_low_date TYPE d,
wa_high_date TYPE d,
wa_index_mat TYPE i,
wa_index_link TYPE i,
wa_level_alv TYPE i.
DATA: g_callback_pgm(40) TYPE c,
g_callback_user_command(30) TYPE c.
DATA: my_print TYPE slis_print_alv.
FIELD-SYMBOLS: <fs_pvwty_dia> TYPE wty_pvwty_dia.
* SELECTION SCREEN *
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK post WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_cpudt FOR s084-spmon NO-EXTENSION,
s_postdt FOR wty_pnwtyv_dia-fkdat NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK post.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_vend FOR pnwtyv-v_parnr NO INTERVALS.
SELECT-OPTIONS: s_clgrp FOR wty_pnwtyh_dia-clmgrp.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: s_model FOR wty_pnwtyh_dia-z_wty_model.
SELECT-OPTIONS: s_matnr FOR mara-matnr.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK lay WITH FRAME TITLE text-004.
PARAMETERS: varn1 TYPE slis_vari MEMORY ID fit_alv_gl, "Dis. variant
varn2 TYPE slis_vari.
SELECTION-SCREEN END OF BLOCK lay.
*$*$----------------------------------------------------------------$*$*
*$*$---A T S E L E C T I O N - S C R E E N-------------------------$*$*
*$*$----------------------------------------------------------------$*$*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR varn1.
PERFORM alv_variant_f4 USING '0001' CHANGING varn1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR varn2.
PERFORM alv_variant_f4 USING '0002' CHANGING varn2.
AT SELECTION-SCREEN ON BLOCK post. "Validate posting parameters
PERFORM validate_posting_parameter.
AT SELECTION-SCREEN ON s_model. "Validate model
PERFORM validate_model.
AT SELECTION-SCREEN ON s_vend. "Validate vendor
PERFORM validate_vendor.
AT SELECTION-SCREEN ON s_matnr. "Validate material
PERFORM validate_material.
AT SELECTION-SCREEN ON s_clgrp. "Validate claim group
PERFORM validate_claim_group.
AT SELECTION-SCREEN OUTPUT.
* Initialization.
INITIALIZATION.
* Initialize default display variant for ALV report
CLEAR gs_variant1.
MOVE sy-repid TO: gs_variant1-report,
gs_variant2-report.
gs_variant1-handle = '0001'.
gs_variant2-handle = '0002'.
wa_lis_progname = sy-repid.
PERFORM set_default_variant CHANGING gs_variant1
varn1.
PERFORM set_default_variant CHANGING gs_variant2
varn2.
PERFORM get_fin_period USING c_year_low c_year_high.
PERFORM set_period_to_analyse.
*$*$----------------------------------------------------------------$*$*
*$*$---S T A R T - O F - S E L E C T I O N--------------------------$*$*
*$*$----------------------------------------------------------------$*$*
START-OF-SELECTION.
PERFORM select_claim_to_process.
*$*$----------------------------------------------------------------$*$*
*$*$---E N D - O F - S E L E C T I O N------------------------------$*$*
*$*$----------------------------------------------------------------$*$*
END-OF-SELECTION.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-m02.
IF sy-batch = 'X'.
PERFORM set_print_alv_grid.
ENDIF.
PERFORM show_alv_grid.
*& Form PRINT_DETAIL_ALV
FORM show_alv_grid.
* Prepare ALV_GRID before display
* ===============================
PERFORM init_field.
PERFORM init_layout.
PERFORM init_fieldcat.
PERFORM init_excluding.
PERFORM init_event.
* SORT report_data BY bukrs werks.
PERFORM call_alv_list_display_level_1.
ENDFORM. " PRINT_DETAIL
*& Form VARIANT_F4 copied from RPCWCCK3
* Display a list of all available display variants for the ALV.
* <--P_varn1 Return the selected variant and return
FORM variant_f4 CHANGING p_varn1 TYPE disvariant-variant.
DATA: l_variant LIKE disvariant.
* Get the list of available variants for the report
l_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = l_variant
i_save = 'A'
IMPORTING
es_variant = l_variant.
p_varn1 = l_variant-variant.
ENDFORM. " VARIANT_F4
*& Form INIT_FIELD
FORM init_field.
MOVE sy-repid TO g_callback_pgm.
MOVE 'MY_USER_COMMAND' TO g_callback_user_command.
ENDFORM. " INIT_FIELD
*& Form INIT_LAYOUT
FORM init_layout.
gs_layout-window_titlebar = sy-title.
gs_layout-colwidth_optimize = 'X'.
gs_layout-expand_all = 'X'.
gs_layout-no_subtotals = ''.
gs_layout-key_hotspot = 'X'. " Afficher Hotspot
gs_layout-zebra = 'X'.
gs_layout-group_change_edit = 'X'.
gs_layout-f2code = 'DISPLAY'.
* gs_layout-max_linesize = 400.
* gs_layout-totals_only = 'X'.
ENDFORM. " INIT_LAYOUT
*& Form INIT_FIELDCAT
FORM init_fieldcat.
DATA: lt_fieldcatalog TYPE lvc_t_fcat,
ltw_fieldcatalog TYPE lvc_s_fcat.
REFRESH: lt_fieldcatalog,
gt_fieldcat_sum,
gt_fieldcat_det.
CLEAR gtw_sort.
REFRESH gt_sort.
* ==============================================
* Set the label column for summary report leve 1
* ==============================================
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZWTY_CLAIM_AVG_REP_SUM'
i_client_never_display = 'X'
CHANGING
ct_fieldcat = lt_fieldcatalog.
* FIELD pos sub up down Group
PERFORM create_sort USING: 'V_PARNR' 1 'X' 'X' ' ' 'X',
'NAME' 2 'X' 'X' ' ' 'X',
'MAKTX' 3 'X' 'X' ' ' 'X',
'MATNR' 4 'X' 'X' ' ' 'X'.
LOOP AT lt_fieldcatalog INTO ltw_fieldcatalog.
CLEAR: gtw_fieldcat.
MOVE-CORRESPONDING ltw_fieldcatalog TO gtw_fieldcat.
PERFORM set_alv_field_desc USING ltw_fieldcatalog '1'.
APPEND gtw_fieldcat TO gt_fieldcat_sum.
ENDLOOP.
PERFORM set_hot_spot TABLES gt_fieldcat_sum USING 'CLAIM_NB'.
* =========================================
* Field Catalog for Detail report (level 2)
* =========================================
REFRESH: lt_fieldcatalog.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZWTY_CLAIM_AVG_REP_DET'
i_client_never_display = 'X'
CHANGING
ct_fieldcat = lt_fieldcatalog.
LOOP AT lt_fieldcatalog INTO ltw_fieldcatalog.
CLEAR: gtw_fieldcat.
MOVE-CORRESPONDING ltw_fieldcatalog TO gtw_fieldcat.
PERFORM set_alv_field_desc USING ltw_fieldcatalog '2'.
APPEND gtw_fieldcat TO gt_fieldcat_det.
ENDLOOP.
PERFORM set_hot_spot TABLES gt_fieldcat_det USING 'CLMNO'.
ENDFORM. " INIT_FIELDCAT
*& Form INIT_SORT
FORM create_sort USING p_fieldname p_spos
p_subtot TYPE char1
p_up TYPE char1
p_down TYPE char1
p_group TYPE char1.
CLEAR: gtw_sort.
gtw_sort-fieldname = p_fieldname.
gtw_sort-spos = p_spos.
gtw_sort-subtot = p_subtot.
gtw_sort-up = p_up.
gtw_sort-down = p_down.
gtw_sort-group = p_group.
APPEND gtw_sort TO gt_sort.
ENDFORM. "create_sort
*& Form INIT_EXCLUDING
* Exclude des option de l'application tool bar
FORM init_excluding.
CLEAR gtw_excluding.
REFRESH gt_excluding.
gtw_excluding-fcode = '&ABC'.
APPEND gtw_excluding TO gt_excluding.
ENDFORM. " INIT_EXCLUDING
*& Form call_alv_list_display_level_1
FORM call_alv_list_display_level_1.
* DATA: l_i_save VALUE 'U'. "User-specific variants only
DATA: l_i_save VALUE 'A'. "Any type of variants
gs_variant1-report = sy-repid.
gs_variant1-variant = varn1.
gs_layout-colwidth_optimize = true.
wa_level_alv = 1.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_callback_pgm
i_callback_user_command = g_callback_user_command
is_layout = gs_layout
it_fieldcat = gt_fieldcat_sum
it_excluding = gt_excluding
it_sort = gt_sort
i_save = l_i_save
is_variant = gs_variant1
it_events = eventcat
is_print = my_print
TABLES
t_outtab = t_summary_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " call_alv_list_display_level_1
*& Form INIT_EVENT
* Determine quelle routine a executer selon l'event
FORM init_event.
eventcat_ln-name = 'TOP_OF_PAGE'.
eventcat_ln-form = 'ALV_PAGE_HEADER'.
APPEND eventcat_ln TO eventcat.
eventcat_ln-name = 'END_OF_PAGE'.
eventcat_ln-form = 'FOOTER_PAGE'.
APPEND eventcat_ln TO eventcat.
ENDFORM. " INIT_EVENT
*& Form ALV_PAGE_HEADER
FORM alv_page_header.
DATA: l_date_time(22),
l_char7(7),
l_char10(10).
DATA: p_date(10) TYPE c.
DATA: p_time(8) TYPE c.
DATA: p_name(80) TYPE c.
* Format current date and time
WRITE sy-datum TO p_date USING EDIT MASK '____/__/__'.
WRITE sy-uzeit TO p_time USING EDIT MASK '__:__:__'.
CONCATENATE p_date '-' p_time
INTO l_date_time SEPARATED BY space.
* Set the user name
SELECT SINGLE
persnumber addrnumber INTO (usr21-persnumber, usr21-addrnumber)
FROM usr21
WHERE bname = sy-uname.
SELECT SINGLE name_first name_last
INTO (adrp-name_first, adrp-name_last )
FROM adrp
WHERE persnumber = usr21-persnumber.
CONCATENATE adrp-name_first adrp-name_last INTO p_name
SEPARATED BY space.
REFRESH gt_top_of_page.
CLEAR gtw_top_of_page.
* Program title ------------------------------------------------
CLEAR gtw_top_of_page.
gtw_top_of_page-typ = 'H'.
gtw_top_of_page-info = sy-title.
APPEND gtw_top_of_page TO gt_top_of_page.
CLEAR gtw_top_of_page.
gtw_top_of_page-typ = 'S'.
gtw_top_of_page-key = 'Parameters :'.
* Period / Posting Date -----------------------------------------
IF s_cpudt[] IS INITIAL.
WRITE s_postdt-low TO l_char10.
CONCATENATE gtw_top_of_page-info
text-104
l_char10
INTO gtw_top_of_page-info SEPARATED BY space.
IF NOT s_postdt-high IS INITIAL.
WRITE s_postdt-high TO l_char10.
CONCATENATE gtw_top_of_page-info
text-105
l_char10
INTO gtw_top_of_page-info SEPARATED BY space.
ENDIF.
APPEND gtw_top_of_page TO gt_top_of_page.
ELSE.
CONCATENATE s_cpudt-low(4) '/' s_cpudt-low+4(2)
INTO l_char7 .
CONCATENATE gtw_top_of_page-info
text-103
l_char7
INTO gtw_top_of_page-info SEPARATED BY space.
IF s_cpudt-high NE space.
CONCATENATE s_cpudt-high(4) '/' s_cpudt-high+4(2)
INTO l_char7 .
CONCATENATE gtw_top_of_page-info
text-105
l_char7
INTO gtw_top_of_page-info SEPARATED BY space.
ENDIF.
APPEND gtw_top_of_page TO gt_top_of_page.
ENDIF.
* Display wich level we display -----------------------------
* IF wa_level_alv > 1.
* CLEAR gtw_top_of_page.
* IF wa_level_alv = 2.
* gtw_top_of_page-info = t_summary_alv-v_parnr.
* SHIFT gtw_top_of_page-info LEFT DELETING LEADING '0'.
* ENDIF.
* gtw_top_of_page-typ = 'S'.
* gtw_top_of_page-key = 'Partner:'.
* APPEND gtw_top_of_page TO gt_top_of_page.
* ENDIF.
* Executed by -----------------------------------------------
CLEAR gtw_top_of_page.
gtw_top_of_page-typ = 'S'.
gtw_top_of_page-key = 'Report executed by :'.
gtw_top_of_page-info = p_name.
* * Date & time of execution --------------------------------
APPEND gtw_top_of_page TO gt_top_of_page.
gtw_top_of_page-key = 'DATE :'.
gtw_top_of_page-info = l_date_time.
APPEND gtw_top_of_page TO gt_top_of_page.
* Name of the report ----------------------------------------
CLEAR gtw_top_of_page.
gtw_top_of_page-typ = 'A'.
* LS_LINE-KEY: not used for this type
gtw_top_of_page-info = sy-repid.
APPEND gtw_top_of_page TO gt_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_top_of_page.
* IF sy-batch = 'X' AND sy-linsz > 255 AND l_ctr_newpage = 0.
* NEW-PAGE PRINT ON LINE-SIZE 255. "Pour wrapper !!!!!!
* ENDIF.
ENDFORM. "ALV_PAGE_HEADER
*& Form footer_page
FORM footer_page.
DATA: l_footer(300),
l_page_no(5).
l_page_no = sy-pagno.
CONCATENATE 'Page' l_page_no INTO l_footer SEPARATED BY space.
SKIP 2.
WRITE:/001 l_footer(sy-linsz) CENTERED.
ENDFORM. "footer_page
*& Form MY_USER_COMMAND
* text
* -->P_SY_UCOMM text
* -->P_GS_SELFIELD text
FORM my_user_command USING p_sy_ucomm
p_gs_selfield TYPE slis_selfield.
DATA: l_claim_no LIKE mcshier-hiername,
lv_tcode_last(15).
* ======================================================
* Call TX WTY to display the claim. Only possible at the
* detail report(level 3)
* ======================================================
CASE p_gs_selfield-fieldname.
WHEN 'CLMNO'.
READ TABLE t_detail_alv INDEX p_gs_selfield-tabindex.
SHIFT t_detail_alv-clmno LEFT DELETING LEADING '0'.
l_claim_no = t_detail_alv-clmno.
CONCATENATE sy-tcode syst-modno
INTO lv_tcode_last.
EXPORT wty_tcode_last_memoid FROM lv_tcode_last TO MEMORY
ID 'WTY_TCODE_LAST_MEMOID'.
SET PARAMETER ID 'CLMNO' FIELD l_claim_no.
CALL TRANSACTION 'WTY' AND SKIP FIRST SCREEN.
WHEN 'CLAIM_NB'.
* =====================================
* Display the next level of information
* =====================================
CASE wa_level_alv.
WHEN 1.
REFRESH: t_detail_alv.
wa_level_alv = 2.
READ TABLE t_summary_alv INDEX p_gs_selfield-tabindex.
LOOP AT t_detail_info
ASSIGNING <fs_detail_info>
WHERE v_parnr EQ t_summary_alv-v_parnr
AND crncy EQ t_summary_alv-crncy
AND item_type EQ t_summary_alv-item_type
AND ov_meinh EQ t_summary_alv-ov_meinh
AND iv_meinh EQ t_summary_alv-iv_meinh
AND matnr EQ t_summary_alv-matnr.
MOVE-CORRESPONDING <fs_detail_info> TO t_detail_alv.
APPEND t_detail_alv.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_callback_pgm
i_callback_user_command = g_callback_user_command
is_layout = gs_layout
it_fieldcat = gt_fieldcat_det
it_excluding = gt_excluding
* it_sort = gt_sort
i_save = c_save
is_variant = gs_variant2
it_events = eventcat
is_print = my_print
TABLES
t_outtab = t_detail_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
wa_level_alv = 1.
ENDCASE.
ENDCASE.
ENDFORM. " MY_USER_COMMAND
* FORM PRINT_ALV_GRID *
* Print the report not on screen for special batch processing. *
* --> IT Table to print - Z_HRF_BEN_CONF_FLEX
FORM set_print_alv_grid.
my_print-print = 'X'. "Force printing
my_print-no_print_selinfos = 'X'.
my_print-no_print_listinfos = 'X'.
my_print-no_new_page = ''. "Separate spool files
my_print-prnt_title = 'X'.
my_print-prnt_info = 'X'.
my_print-reserve_lines = 3.
ENDFORM. "set_print_alv_grid
*& Form ALV_VARIANT_F4
FORM alv_variant_f4 USING p_handle
CHANGING p_vari.
DATA: rs_variant LIKE disvariant.
DATA: nof4 TYPE c.
CLEAR nof4.
LOOP AT SCREEN.
IF screen-name = p_vari.
IF screen-input = 0.
nof4 = 'X'.
ENDIF.
ENDIF.
ENDLOOP.
rs_variant-report = sy-repid.
rs_variant-username = sy-uname.
rs_variant-handle = p_handle.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = rs_variant
i_save = 'A'
IMPORTING
es_variant = rs_variant
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0 AND nof4 EQ space.
p_vari = rs_variant-variant.
ENDIF.
ENDFORM. " ALV_VARIANT_F4
*& Form validate_model
* text
* --> p1 text
* <-- p2 text
FORM validate_model .
DATA: l_matnr LIKE mara-matnr.
SELECT SINGLE matnr
INTO l_matnr
FROM mara
WHERE matnr IN s_model
AND mtart EQ 'ZKMA'.
IF sy-subrc NE 0.
MESSAGE e000 WITH text-e07.
ENDIF.
ENDFORM. " validate_model
*& Form select_claim_to_process
* text
* --> p1 text
* <-- p2 text
FORM select_claim_to_process .
DATA: lt_pnwtyh_dia TYPE wty_pnwtyh_dia_tab,
lt_pnwtyv_dia TYPE wty_pnwtyv_dia_tab,
lt_pvwty_dia TYPE wty_pvwty_dia_tab,
lt_pnwtyh_dia_tmp TYPE wty_pnwtyh_dia_tab,
lt_pnwtyv_dia_tmp TYPE wty_pnwtyv_dia_tab,
lt_pvwty_dia_tmp TYPE wty_pvwty_dia_tab,
lt_pvwty_dia_mat TYPE wty_pvwty_dia_tab,
lt_sel_fkdat TYPE pwty_sel_fkdat_pt,
lt_sel_v_parnr TYPE pwty_sel_v_parnr_pt,
lt_sel_clmty TYPE pwty_sel_clmty_pt,
lt_sel_clmgrp TYPE pwty_sel_clmgrp_pt.
DATA: lst_sel_fkdat LIKE LINE OF lt_sel_fkdat,
lst_sel_clmty LIKE LINE OF lt_sel_clmty.
DATA: BEGIN OF lt_clmno OCCURS 0,
clmno LIKE pnwtyh-clmno,
END OF lt_clmno,
lt_clmno_tmp LIKE lt_clmno OCCURS 0,
lt_claim TYPE pwty_sel_clmno_pt,
wa_clmno LIKE LINE OF lt_claim.
DATA: l_nb_claim TYPE i.
RANGES: lr_model FOR wty_pnwtyh_dia-z_wty_model.
FIELD-SYMBOLS: <lfs_pnwtyh_dia> LIKE LINE OF lt_pnwtyh_dia,
<lfs_pnwtyv_dia> LIKE LINE OF lt_pnwtyv_dia,
<lfs_pvwty_dia_es2> LIKE LINE OF lt_pvwty_dia,
<lfs_pvwty_dia_mat> LIKE LINE OF lt_pvwty_dia_mat.
REFRESH: lt_pnwtyh_dia, lt_pnwtyv_dia,lt_pvwty_dia, lt_sel_clmty,
lr_model, t_detail_info, t_summary_alv, lt_pvwty_dia_mat.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-m01. "Extracting claim
* ========================
* Get the Claim to process
* ========================
* SELECT clmno
* INTO TABLE lt_clmno
* FROM pnwtyh
* WHERE z_wty_convflg EQ space
* AND z_wty_error EQ space
* wa_clmno-sign = 'I'.
* wa_clmno-option = 'EQ'.
* LOOP AT lt_clmno.
* wa_clmno-low = lt_clmno-clmno.
* APPEND wa_clmno TO lt_claim.
* ENDLOOP.
lst_sel_fkdat-sign = 'I'.
lst_sel_fkdat-option = 'BT'.
lst_sel_fkdat-low = wa_low_date.
lst_sel_fkdat-high = wa_high_date.
APPEND lst_sel_fkdat TO lt_sel_fkdat.
lst_sel_clmty-sign = 'E'.
lst_sel_clmty-option = 'EQ'.
lst_sel_clmty-low = 'ZSBC'.
APPEND lst_sel_clmty TO lt_sel_clmty.
lt_sel_v_parnr[] = s_vend[].
lt_sel_clmgrp[] = s_clgrp[].
CALL FUNCTION 'PVSDBWTY_CLAIM_SELECT'
EXPORTING
it_sel_fkdat = lt_sel_fkdat
it_sel_clmgrp = lt_sel_clmgrp
it_sel_v_parnr = lt_sel_v_parnr
it_sel_clmty = lt_sel_clmty
* it_sel_clmno = lt_claim
IMPORTING
et_pnwtyh_dia = lt_pnwtyh_dia
et_pnwtyv_dia = lt_pnwtyv_dia
et_pvwty_dia = lt_pvwty_dia
EXCEPTIONS
no_entry_found = 1
authority_failed = 2
OTHERS = 3.
IF sy-subrc = 3 .
MESSAGE e309(wty) .
ENDIF .
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-m03. "Extracting claim
LOOP AT lt_pvwty_dia
ASSIGNING <fs_pvwty_dia>
WHERE poskt_cust = 'MAT'.
INSERT <fs_pvwty_dia> INTO TABLE lt_pvwty_dia_mat.
ENDLOOP.
it_pvwty_dia_all[] = lt_pvwty_dia[].
SORT lt_pnwtyh_dia BY pnguid.
SORT lt_pvwty_dia BY version_guid z_wty_posnr_hier.
SORT lt_pvwty_dia_mat BY version_guid.
SORT it_pvwty_dia_all BY version_guid posnr.
* Keep Version record OC or IV in a separate table for later use
LOOP AT lt_pnwtyv_dia
ASSIGNING <lfs_pnwtyv_dia>.
it_submit_records-header_guid = <lfs_pnwtyv_dia>-header_guid.
it_submit_records-versn = <lfs_pnwtyv_dia>-versn.
it_submit_records-prev_version = <lfs_pnwtyv_dia>-prev_version.
it_submit_records-kateg = <lfs_pnwtyv_dia>-kateg.
it_submit_records-aktiv = <lfs_pnwtyv_dia>-aktiv.
it_submit_records-knumv = <lfs_pnwtyv_dia>-knumv.
it_submit_records-pnguid = <lfs_pnwtyv_dia>-pnguid.
INSERT TABLE it_submit_records.
ENDLOOP.
* =============
* Process Claim
* =============
LOOP AT lt_pnwtyv_dia
ASSIGNING <lfs_pnwtyv_dia>
WHERE aktiv EQ true "Active version only
AND kateg EQ 'IV' "Category
AND fi_doc_exist EQ 'X'.
CLEAR: t_detail_info, t_summary_alv.
* Read Header detail
READ TABLE lt_pnwtyh_dia
WITH KEY pnguid = <lfs_pnwtyv_dia>-header_guid
ASSIGNING <lfs_pnwtyh_dia>
BINARY SEARCH.
* Claim must be without error -----------------------------
IF sy-subrc NE 0 OR
<lfs_pnwtyh_dia>-z_wty_error = true OR
<lfs_pnwtyh_dia>-z_wty_convflg = true.
CONTINUE. "Rejected this Claim
ENDIF.
* Check Model
IF <lfs_pnwtyh_dia>-z_wty_model IN s_model.
ELSE.
CONTINUE. "Rejected this Claim
ENDIF.
* Read first "MAT" Item information ------------------
READ TABLE lt_pvwty_dia_mat
WITH KEY version_guid = <lfs_pnwtyv_dia>-pnguid
ASSIGNING <lfs_pvwty_dia_mat>
BINARY SEARCH.
wa_index_mat = sy-tabix.
IF sy-subrc NE 0.
CONTINUE. "Rejected this Claim
ENDIF.
* ====================================================
* Process all item "MAT" linked to the current version
* ====================================================
WHILE sy-subrc = 0
AND
<lfs_pvwty_dia_mat>-version_guid = <lfs_pnwtyv_dia>-pnguid.
IF <lfs_pvwty_dia_mat>-matnr IN s_matnr.
* ======================================
* Process Items linked to the "MAT" Item
* ======================================
READ TABLE lt_pvwty_dia
WITH KEY version_guid = <lfs_pnwtyv_dia>-pnguid
z_wty_posnr_hier = <lfs_pvwty_dia_mat>-posnr
ASSIGNING <lfs_pvwty_dia_es2>
BINARY SEARCH.
wa_index_link = sy-tabix.
DO. "Execute only ONCE (to process all items linked to the)
"MAT Item
IF sy-subrc NE 0.
EXIT. "Exit the DO loop
ENDIF.
WHILE sy-subrc = 0
AND
<lfs_pvwty_dia_es2>-version_guid =
<lfs_pnwtyv_dia>-pnguid
AND
<lfs_pvwty_dia_es2>-z_wty_posnr_hier =
<lfs_pvwty_dia_mat>-posnr.
IF <lfs_pvwty_dia_es2>-valiv EQ c_zero.
ELSE.
* Initialize the detail information to display ---------
CLEAR: t_detail_info.
t_detail_info-v_parnr = <lfs_pnwtyv_dia>-v_parnr.
t_detail_info-matnr = <lfs_pvwty_dia_mat>-matnr.
t_detail_info-item_type = <lfs_pvwty_dia_es2>-poskt_cust.
t_detail_info-iv_versn = <lfs_pnwtyv_dia>-versn.
t_detail_info-clmno = <lfs_pnwtyh_dia>-clmno.
t_detail_info-crncy = <lfs_pnwtyv_dia>-v_crncy.
t_detail_info-iv_meinh = <lfs_pvwty_dia_es2>-meinh.
t_detail_info-z_wty_model = <lfs_pnwtyh_dia>-z_wty_model.
ADD <lfs_pvwty_dia_es2>-quant TO
t_detail_info-iv_appr_qty.
SELECT SINGLE kbetr
INTO t_detail_info-iv_appr_rate
FROM konv
WHERE knumv = <lfs_pnwtyv_dia>-knumv
AND kposn = <lfs_pvwty_dia_es2>-posnr
AND kschl = 'ZVAP'
AND kinak = space.
* t_detail_info-flat_indic = <lfs_pnwtyh_dia>-z_wty_model
* t_detail_info-pric_indic = <lfs_pnwtyh_dia>-z_wty_serno
PERFORM get_the_submit_record
USING <lfs_pnwtyv_dia>-header_guid
<lfs_pnwtyv_dia>-prev_version
<lfs_pnwtyh_dia>-clmno
<lfs_pvwty_dia_es2>-posnr.
ENDIF.
* =====================
* Read next Linked item
* =====================
PERFORM read_next_item TABLES lt_pvwty_dia
CHANGING wa_index_link.
IF sy-subrc = 0.
ASSIGN <fs_pvwty_dia> TO <lfs_pvwty_dia_es2>.
ENDIF.
ENDWHILE.
EXIT. "Exit the DO loop
ENDDO.
ENDIF.
* ====================
* Read next "MAT" item
* ====================
PERFORM read_next_item TABLES lt_pvwty_dia_mat
CHANGING wa_index_mat.
IF sy-subrc = 0.
ASSIGN <fs_pvwty_dia> TO <lfs_pvwty_dia_mat>.
ENDIF.
ENDWHILE.
ENDLOOP.
* ========================
* Get the description text
* ========================
LOOP AT t_detail_info
ASSIGNING <fs_detail_info>.
* Get the model text -------------------------------------
SELECT SINGLE mfrpn
INTO <fs_detail_info>-z_wty_model
FROM mara
WHERE matnr = <fs_detail_info>-z_wty_model.
* Set Node name to regroup later by group -----------------
SELECT SINGLE name1
INTO <fs_detail_info>-name
FROM lfa1
WHERE lifnr = <fs_detail_info>-v_parnr.
* Set Node name to regroup later by group -----------------
SELECT SINGLE maktx
INTO <fs_detail_info>-maktx
FROM makt
WHERE matnr = <fs_detail_info>-matnr
AND spras = sy-langu.
MOVE-CORRESPONDING <fs_detail_info> TO t_summary_alv.
t_summary_alv-claim_nb = 1.
COLLECT t_summary_alv.
ENDLOOP.
* ===========================================
* Calculate the average of the summary report
* ===========================================
LOOP AT t_summary_alv
ASSIGNING <fs_summary_alv>.
DIVIDE <fs_summary_alv>-ov_prop_qty BY <fs_summary_alv>-claim_nb.
DIVIDE <fs_summary_alv>-ov_prop_rate BY <fs_summary_alv>-claim_nb.
DIVIDE <fs_summary_alv>-ov_submit_qty BY <fs_summary_alv>-claim_nb.
DIVIDE <fs_summary_alv>-ov_submit_rate BY <fs_summary_alv>-claim_nb.
DIVIDE <fs_summary_alv>-iv_appr_qty BY <fs_summary_alv>-claim_nb.
DIVIDE <fs_summary_alv>-iv_appr_rate BY <fs_summary_alv>-claim_nb.
ENDLOOP.
DELETE t_summary_alv WHERE v_parnr NOT IN s_vend.
ENDFORM. " select_claim_to_process
*& Form SET_HOT_SPOT
* text
* -->P_0287 text
FORM set_hot_spot TABLES p_fieldcat TYPE slis_t_fieldcat_alv
USING value(p_field).
FIELD-SYMBOLS: <lfs_field_cat> LIKE LINE OF gt_fieldcat_sum.
READ TABLE p_fieldcat WITH KEY fieldname = p_field
ASSIGNING <lfs_field_cat>.
IF sy-subrc = 0.
<lfs_field_cat>-hotspot = 'X'.
<lfs_field_cat>-key = 'X'.
ENDIF.
ENDFORM. " SET_HOT_SPOT
*& Form set_screen_text
* text
* -->P_0997 text
FORM set_screen_text USING p_label
p_text.
MOVE p_label TO :gtw_fieldcat-seltext_l,
gtw_fieldcat-seltext_m,
gtw_fieldcat-seltext_s,
gtw_fieldcat-reptext_ddic.
IF p_text NE space.
gtw_fieldcat-ddictxt = p_text.
ENDIF.
ENDFORM. " set_screen_text
*& Form set_default_variant
* text
* -->P_0822 text
* <--P_GS_VARIANT1 text
FORM set_default_variant CHANGING p_variant TYPE disvariant
p_disvar TYPE slis_vari.
* Get default variant
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = c_save
CHANGING
cs_variant = p_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_disvar = p_variant-variant.
ENDIF.
ENDFORM. " set_default_variant
*& Form validate_vendor
* text
* --> p1 text
* <-- p2 text
FORM validate_vendor.
DATA: l_lifnr LIKE lfa1-lifnr.
IF s_vend[] IS INITIAL.
ELSE.
SELECT SINGLE lifnr
INTO l_lifnr
FROM lfa1
WHERE lifnr IN s_vend.
IF sy-subrc NE 0.
MESSAGE e000 WITH text-e01.
ENDIF.
ENDIF.
ENDFORM. " validate_vendor
*& Form inform_claim_error
* text
* --> p1 text
* <-- p2 text
FORM inform_claim_error USING value(p_claim_no)
value(p_version).
DATA: l_text1(50),
l_text2(50).
CONCATENATE text-301
p_claim_no
INTO l_text1 SEPARATED BY space.
CONCATENATE text-302
p_version
text-303
INTO l_text2 SEPARATED BY space.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = text-200
txt1 = l_text1
txt2 = l_text2
txt3 = ' '
txt4 = text-304.
ENDFORM. " inform_claim_error
*& Form validate_posting_parameter
* text
* --> p1 text
* <-- p2 text
FORM validate_posting_parameter .
DATA: l_low_date TYPE d,
l_high_date TYPE d.
CLEAR: wa_low_date, wa_high_date.
* Posting parameters must be entered
IF s_cpudt[] IS INITIAL AND s_postdt[] IS INITIAL.
MESSAGE e000 WITH text-e04.
ENDIF.
* Posting paramters can't be intered at the same time
IF s_cpudt[] IS INITIAL OR s_postdt[] IS INITIAL.
ELSE.
MESSAGE e000 WITH text-e03.
ENDIF.
* Validate posting period ---------------------------------------------
IF s_postdt[] IS INITIAL.
READ TABLE s_cpudt INDEX 1.
IF s_cpudt-low IS INITIAL.
MESSAGE e000 WITH text-e03.
ENDIF.
PERFORM validate_period USING s_cpudt-low
CHANGING l_low_date
l_high_date.
wa_low_date = l_low_date.
wa_high_date = l_high_date.
IF s_cpudt-high IS INITIAL.
ELSE.
PERFORM validate_period USING s_cpudt-high
CHANGING l_low_date
l_high_date.
IF s_cpudt-high LT s_cpudt-low.
MESSAGE ID 'DB' TYPE 'E' NUMBER '650' .
ENDIF.
wa_high_date = l_high_date.
ENDIF.
ELSE.
* Validate posting date --------------------------------------------
READ TABLE s_postdt INDEX 1.
wa_low_date = s_postdt-low.
IF s_postdt-high IS INITIAL.
wa_high_date = wa_low_date.
ELSE.
wa_high_date = s_postdt-high.
ENDIF.
ENDIF.
ENDFORM. " validate_posting_parameter
*& Form get_fin_period
* Get the financial period from 1960 to 9999
* --> p1 text
* <-- p2 text
FORM get_fin_period USING value(p_year_low)
value(p_year_high).
DATA : BEGIN OF fp_table OCCURS 0,
periv LIKE t009b-periv, "FINANCIAL YEAR VARIANT
bdatj LIKE t009b-bdatj, "CALENDAR YEAR
bumon LIKE t009b-bumon, "MONTH
butag LIKE t009b-butag, "DAY OF MONTH
poper LIKE t009b-poper, "COST PERIOD
reljr LIKE t009b-reljr, "YEAR SHIFT
END OF fp_table.
DATA: l_fin_bdatj LIKE t009b-bdatj,
l_period_start TYPE d,
l_period_end TYPE d,
l_prev_period_end TYPE d,
l_prev_fin_bdatj LIKE t009b-bdatj,
l_prev_poper LIKE t009b-poper,
l_count TYPE n.
* Get the Fiscal year variant periods
SELECT periv bdatj bumon butag poper reljr
INTO TABLE fp_table
FROM t009b
WHERE periv = 'ZB'.
LOOP AT fp_table.
IF l_prev_period_end NE '00000000'.
l_period_start = l_prev_period_end + 1.
ENDIF.
CONCATENATE fp_table-bdatj fp_table-bumon fp_table-butag
INTO l_period_end.
l_prev_period_end = l_period_end.
l_fin_bdatj = fp_table-bdatj + fp_table-reljr.
IF c_year_low NE '' AND l_fin_bdatj LT p_year_low.
CONTINUE.
ELSEIF p_year_high NE '' AND l_fin_bdatj GT p_year_high.
CONTINUE.
ELSEIF p_year_low NE '' AND p_year_high EQ '' AND
l_fin_bdatj GT c_year_low.
CONTINUE.
ENDIF.
IF l_prev_fin_bdatj EQ l_fin_bdatj AND
l_prev_poper EQ fp_table-poper.
it_period-end = l_period_end.
MODIFY it_period TRANSPORTING end
WHERE year = it_period-year
AND poper = it_period-poper.
ELSE.
it_period-year = l_fin_bdatj.
it_period-poper = fp_table-poper+1.
it_period-start = l_period_start.
it_period-end = l_period_end.
INSERT TABLE it_period.
ENDIF.
l_prev_fin_bdatj = l_fin_bdatj.
l_prev_poper = fp_table-poper.
IF l_count EQ 0.
l_count = l_count + 1.
ENDIF.
ENDLOOP.
ENDFORM. " get_fin_period
*& Form set_period_to_analyse
* Find the fiscal period for a specific date
* --> p1 text
* <-- p2 text
FORM set_period_to_analyse.
LOOP AT it_period
ASSIGNING <fs_it_period>
WHERE start LE sy-datum
AND end GE sy-datum.
CONCATENATE <fs_it_period>-year
<fs_it_period>-poper
INTO s_cpudt-low.
s_cpudt-sign = 'I'.
s_cpudt-option = 'EQ'.
APPEND s_cpudt.
EXIT.
ENDLOOP.
ENDFORM. " set_period_to_analyse
*& Form validate_material
* text
* --> p1 text
* <-- p2 text
FORM validate_material .
DATA: l_matnr LIKE mara-matnr.
IF s_matnr[] IS INITIAL.
ELSE.
SELECT SINGLE matnr
INTO l_matnr
FROM mara
WHERE matnr IN s_matnr.
IF sy-subrc NE 0.
MESSAGE e000 WITH text-e02.
ENDIF.
ENDIF.
ENDFORM. " validate_material
*& Form validate_claim_group
* text
* --> p1 text
* <-- p2 text
FORM validate_claim_group .
DATA: l_clmgrp LIKE cwty006-clmgrp.
IF s_clgrp[] IS INITIAL.
ELSE.
SELECT SINGLE clmgrp
INTO l_clmgrp
FROM cwty006
WHERE clmgrp IN s_clgrp.
IF sy-subrc NE 0.
MESSAGE e000 WITH text-e06.
ENDIF.
ENDIF.
ENDFORM. " validate_claim_group
*& Form set_alv_field_desc
* text
* -->P_LTW_FIELDCATALOG text
* <--P_GTW_FIELDCAT text
FORM set_alv_field_desc USING value(p_fieldcat) TYPE lvc_s_fcat
value(p_level).
gtw_fieldcat-seltext_l = p_fieldcat-scrtext_l.
gtw_fieldcat-seltext_m = p_fieldcat-scrtext_m.
gtw_fieldcat-seltext_s = p_fieldcat-scrtext_s.
gtw_fieldcat-reptext_ddic = p_fieldcat-reptext.
CASE p_fieldcat-fieldname.
WHEN 'NAME'.
PERFORM set_screen_text USING 'Vendor Name' 'L'.
WHEN 'MAKTX'.
PERFORM set_screen_text USING 'Material Description' 'L'.
WHEN 'CLAIM_NB'.
PERFORM set_screen_text USING '#Claims' 'L'.
WHEN 'IV_MEINH'.
PERFORM set_screen_text USING 'IV UoM' 'L'.
WHEN 'OV_MEINH'.
PERFORM set_screen_text USING 'OV UoM' 'L'.
WHEN 'FLAT_INDIC'.
PERFORM set_screen_text USING 'Flat Rate Ind.' 'L'.
WHEN 'PRIC_INDIC'.
PERFORM set_screen_text USING 'Price Ind.' 'L'.
WHEN 'OV_PROP_QTY'.
IF p_level = 1. "Summary report
*BEGIN OF TR#D03K935718
* PERFORM set_screen_text USING 'OV avg. Prop. Qty' 'L'.
PERFORM set_screen_text USING 'Avg Prop Qty Sub' 'L'. "RFC2917
*END OF TR#D03K935718
ELSE.
PERFORM set_screen_text USING 'OV Prop. Qty' 'L'.
ENDIF.
WHEN 'OV_PROP_RATE'.
IF p_level = 1. "Summary report
*BEGIN OF TR#D03K935718
* PERFORM set_screen_text USING 'OV avg. Prop. Rate $' 'L'.
PERFORM set_screen_text USING 'Avg Prop Rate Sub' 'L'. "RFC2917
*END OF TR#D03K935718
ELSE.
PERFORM set_screen_text USING 'OV Prop. Rate $' 'L'.
ENDIF.
WHEN 'OV_SUBMIT_QTY'.
IF p_level = 1. "Summary report
*BEGIN OF TR#D03K935718
* PERFORM set_screen_text USING 'OV avg. Submit Qty' 'L'.
PERFORM set_screen_text USING 'Avg Qty Sub' 'L'. "RFC2917
*END OF TR#D03K935718
ELSE.
PERFORM set_screen_text USING 'OV Submit Qty' 'L'.
ENDIF.
WHEN 'OV_SUBMIT_RATE'.
IF p_level = 1. "Summary report
*BEGIN OF TR#D03K935718
* PERFORM set_screen_text USING 'OV avg. Submit Rate $' 'L'.
PERFORM set_screen_text USING 'Avg Rate Sub' 'L'. "RFC2917
*END OF TR#D03K935718
ELSE.
PERFORM set_screen_text USING 'OV Submit Rate $' 'L'.
ENDIF.
WHEN 'IV_APPR_QTY'.
IF p_level = 1. "Summary report
*BEGIN OF TR#D03K935718
* PERFORM set_screen_text USING 'IV Avg. Appr. Qty' 'L'.
PERFORM set_screen_text USING 'Avg Qty Pd' 'L'. "RFC2917
*END OF TR#D03K935718
ELSE.
PERFORM set_screen_text USING 'IV Appr. Qty' 'L'.
ENDIF.
WHEN 'IV_APPR_RATE'.
IF p_level = 1. "Summary report
*BEGIN OF TR#D03K935718
* PERFORM set_screen_text USING 'IV Avg. Appr. Rate $' 'L'.
PERFORM set_screen_text USING 'Avg Rate Pd' 'L'. "RFC2917
*END OF TR#D03K935718
ELSE.
PERFORM set_screen_text USING 'IV Appr. Rate $' 'L'.
ENDIF.
WHEN 'OV_VERSN'.
PERFORM set_screen_text USING 'OV Versn.' 'L'.
WHEN 'IV_VERSN'.
PERFORM set_screen_text USING 'IV Versn.' 'L'.
WHEN OTHERS.
gtw_fieldcat-ddictxt = p_fieldcat-selddictxt.
ENDCASE.
* Initialisation des Labels des entetes de colonne -------------------
gtw_fieldcat-no_out = p_fieldcat-no_out.
gtw_fieldcat-emphasize = p_fieldcat-emphasize.
gtw_fieldcat-fix_column = p_fieldcat-fix_column.
gtw_fieldcat-icon = p_fieldcat-icon.
gtw_fieldcat-no_zero = 'X'.
gtw_fieldcat-do_sum = p_fieldcat-do_sum.
ENDFORM. " set_alv_field_desc
*& Form validate_period
* text
* -->P_S_CPUDT_LOW text
FORM validate_period USING value(p_period)
CHANGING p_low_date TYPE d
p_high_date TYPE d.
DATA: l_year(4),
l_poper(2).
l_year = p_period(4).
l_poper = p_period+4(2).
READ TABLE it_period WITH KEY year = l_year
poper = l_poper
ASSIGNING <fs_it_period>.
IF sy-subrc NE 0.
MESSAGE e000 WITH text-e04.
ENDIF.
p_low_date = <fs_it_period>-start.
p_high_date = <fs_it_period>-end.
ENDFORM. " validate_period
*& Form read_next_item
* text
* --> p1 text
* <-- p2 text
FORM read_next_item TABLES pt_pvwty_dia STRUCTURE wty_pvwty_dia
CHANGING p_index TYPE i.
p_index = p_index + 1.
* Read next Item information ------------------------------
READ TABLE pt_pvwty_dia INDEX p_index
ASSIGNING <fs_pvwty_dia>.
ENDFORM. " read_next_item
*& Form get_the_submit_record
* text
* -->P_<LFS_PNWTYV_DIA>_HEADER_GUID text
* -->P_<LFS_PNWTYV_DIA>_PREV_VERSION text
FORM get_the_submit_record USING p_header_guid
p_prev_version
p_claim_no
p_posnr.
DATA: l_nb_while TYPE i,
l_zaehk LIKE konv-zaehk,
l_submit_found(1).
* ... USD1092841 - Add Start
FIELD-SYMBOLS: <fs_submit_rec_vs3> TYPE tp_submit_records.
* ... USD1092841 - Add End
CLEAR: l_submit_found, l_nb_while.
READ TABLE it_submit_records
WITH KEY header_guid = p_header_guid
versn = p_prev_version
ASSIGNING <fs_submit_rec_vs2>.
WHILE sy-subrc = 0 .
ADD 1 TO l_nb_while.
* if more than 30 loop(endless loop), it means somHi Siddarth
As per query, if you want to display sums automatically when you report is displayed for the first time, you'll have to modify your field catalog a bit.
To acheive this, you need to identify the field for which the totals are calculated ex- for every new material num, or for every new documnet number etc.
once you have this info, you identify the field that has to be totaled.
then while building your fieldcatalog, set this parameter :
l_wa_fieldcat-do_sum = 'X' for the field that has to be totaled.
and when you build a sort table then set this parameter:
l_t_sort TYPE slis_t_sortinfo_alv.
l_s_sort-subtot = 'X'. for the field for which totals are calculated.
Hope this helps.
Cheers
Ravish
Reward if helpful -
Summing up a Column in ALV report
Hi All,
I have developed an ALV Report which will display Invoices and other details.
Now i need to display the sum of NETWR column, if user wish to select that column and click the "SUM" icon.
As of now, if i select the NETWR column and click 'SUM" column, i am getting Runtime error.
How to resolve this issue?
Regards
PavanHi Pavan,
ALV GRID CONTROL:
This task is performed by the SAP Control Framework.
The R/3 System allows you to create custom controls using ABAP Objects. The application server is the Automation Client, which drives the custom controls (automation server) at the front end.
If custom controls are to be included on the frontend, then the SAPGUI acts as a container for them.
Custom controls can be ActiveX Controls or JavaBeans.
The system has to use a Remote Function Call (RFC) to transfer methods for creating and using a control to the front end.
ABAP objects are used to implement the controls in programs.
An SAP Container can contain other controls (for example, SAP ALV Grid Control, Tree Control, SAP Picture Control, SAP Splitter Control, and so on). It administers these controls logically in one collection and provides a physical area for the display.
Every control exists in a container. Since containers are themselves controls, they can be nested within one another. The container becomes the parent of its control. SAP containers are divided into five groups:
SAP custom container: Displays within an area defined in Screen Painter on screens or sub screens.
Class: CL_GUI_CUSTOM_CONTAINER
SAP dialog box container: Displays in a modeless dialog box or as a full screen. Class:
CL_GUI_DIALOGBOX_CONTAINER
SAP docking container: Displays as docked, resizable sub-window with the option of displaying it as a modeless dialog box. Class: CL_GUI_DOCKING_CONTAINER
SAP splitter container: Displays and groups several controls in one area - that is, splits the area into cells Class: CL_GUI_SPLITTER_CONTAINER
SAP easy splitter container: Displays controls in two cells, which the user can resize using a split bar. Class: CL_GUI_EASY_SPLITTER_CONTAINER.
In the control, you can adjust the column width by dragging, or use the 'Optimum width' function to adjust the column width to the data currently displayed. You can also change the column sequence by selecting a column and dragging it to a new position.
Standard functions are available in the control toolbar. The details display displays the fields in the line on which the cursor is positioned in a modal dialog box.
The sort function in the ALV Control is available for as many columns as required. You can set complex sort criteria and sort columns in either ascending or descending order.
You can use the 'Search' function to search for a string (generic search without *) within a selected area by line or column.
You can use the 'Sum' function to create totals for one or more numeric columns. You can then use the "Subtotals" function to set up control level lists: You can use the 'Subtotal' function to structure control level lists: select the columns (non-numeric columns only) that you want to use and the corresponding control level totals are displayed.
For 'Print' and 'Download' the whole list is always processed, not just the sections displayed on the screen.
You can define display variants to meet your own specific requirements. For information on saving variants, see 'Advanced Techniques'.
The ALV grid control is a generic tool for displaying lists in screens. The control offers standard functions such as sorting by any column, adding numeric columns, and fixed lead columns .
Data collection is performed in the program (with SELECT statements, for example) or by using a logical database. The data records are saved in an internal table and passed on to the ALV control along with a field description.
The field description contains information about the characteristics of each column, such as the column header and output length. This information can defined either globally in the Dictionary (structure in the Dictionary) or in the field catalog in the program itself. You can also merge both techniques.
The ALV link is a standard function of Query and QuickViewer. If multiline queries or Quick View lists have been defined, they will automatically be compressed to a single line and output in the ALV control as a long, single line list.
Use Screen Painter to create a sub screen container for the ALV grid control. The control requires an area where it can be displayed in the screen. You have to create a container control that determines this area.
Use the corresponding icon in the Screen Painter layout to create the container control. The size of area "MY_CONTROL_AREA" determines the subsequent size of the ALV control.
The valid GUI status must be set at the PBO event in the flow logic of the ALV subscreen container.
The OK_CODE processing for the cancel functions must be programmed at the PAI event.
The reference variables for the custom container and the ALV grid control must be declared.
To create reference variables, use ABAP statement TYPE REF TO .
The global classes you need to do this are called cl_gui_custom_container (for the custom container control) and cl_gui_alv_grid (for the ALV grid control).
The global classes are defined in the Class Builder. You can use the Class Builder to display information for the methods, their parameters, exceptions, and so on.
Use ABAP statement CREATE OBJECT to create the objects for the container and the ALV control. Objects Are instances of a class.
When an object is created (CREATE), method CONSTRUCTOR of the corresponding class is executed. The parameters of method CONSTRUCTOR determine which parameters have to be supplied with data when the object is created. In the above example, object alv_grid is given the name of the container control (g_custom_container) in exporting parameter i_parent, which links the two controls. For information on which parameters method CONSTRUCTOR possesses and which of these parameters are required, see the Class Builder.
Objects should only be created once during the program. To ensure that this is the case, enclose the CREATE OBJECT statement(s) in an IF IS INITIAL. ... ENDIF clause. The objects must be generated before the control is displayed for the first time - that is, during the PBO event of the ALV subscreen container.
To display the requested dataset in the ALV control, the data must be passed on to the control as an internal table, and a field description must exist indicating the order in which the columns will be output.
In the simplest case, the field description can use a structure from the Dictionary. The Dictionary also determines the technical field attributes like type and length, as well as the semantic attributes like short and long texts. The ALV control uses this information to determine the column widths and headers. The column sequence is determined by the field sequence in the structure.
If no suitable structure is active in the Dictionary, or you want to output internal program fields in the control, then you will have to define information like the output length and column header in the field catalog.
In a typical program run, the dataset is read first (SELECT ....), the internal table is filled with the data to display (... INTO TABLE ...), and ABAP statement CALL SCREEN is then used to call the ALV sub screen container.
The data transfer to the ALV control takes place during the call of method
set_table_for_first_display from class cl_gui_alv_grid. The method call must be programmed at the PBO event of the ALV subscreen container.
The name of the Dictionary structure that supplies the field description is specified in exporting parameter i_structure_name. The name of the internal table that contains the data records to display is specified in changing parameter it_outtab.
The field description for the ALV control can be ta ken from an active Dictionary structure (fully automatic), by passing a field catalog (manual), or through a mixture of the two options (merge).
The field catalog is in internal table with type lvc_t_fcat. This type is defined globally in the Dictionary.
Each line in the field catalog table corresponds to a column in the ALV control.
The field characteristics (= column characteristics) are defined in the field catalog. The field catalog is in internal table with type lvc_t_fcat. Each line that is explicitly described in the ALV control corresponds to a column in the field catalog table.
The link to the data records to output that are saved in internal table is established through field name . This name must be specified in column "fieldname" in the field catalog.
This field can be classified through a Dictionary reference (ref_table and ref_field) or by specifying an ABAP data type (inttype).
Column headers and field names in the detail view of an ALV control line can be determined in the field catalog in coltext and seltext, respectively.
The position of a field during output can be determined with col_pos in the field catalog.
If you want to hide a column, fill field no_out with an "X" in the field catalog. Hidden fields can be displayed again in a user display variant.
Icons can be displayed in the ALV control. If you want a column to be interpreted as an icon, then the icon name must be known to the program (include .) and icon = "X" must be specified for this column in the field catalog.
The above example shows a semi-automatic field description: Part of the field description comes from the Dictionary structure (sflight), while another part is explicitly defined in the field catalog (gt_fieldcat).
The field catalog (internal table) is filled in the program and is passed on together with the name of the Dictionary structure during the method call. The information is merged accordingly in method set_table_for_first_display.
For a user to save display variants, parameters is_variant and i_save must be passed on during method call set_table_for_first_screen. To assign display variants uniquely to a program, at least the program name must be supplied in the transferred structure (gs_variant).
Program names can be up to 30 characters long.
If you only pass on the current parameters for is_variant, then existing variants can be loaded, but no new ones can be saved. If you use parameter i_save, you must pass on a variant structure with is_variant.
I_SAVE = SPACE No variants can be saved.
I_SAVE = 'U' The user can only save user-specific variants.
I_SAVE = 'X' The user can only save general (shared) variants.
I_SAVE = 'A' The user can save both user-specific and general (shared) variants.
You can use parameter is_layout of method set_table_for_first_display, for example, to define the header in the ALV control and the detail display.
To do this, define a query area in the program in accordance with Dictionary structure lvc_s_layo, and pass on the text to display in field -grid_title or -detailtitl.
If you want to create print lists with zebra stripes, set field -zebra to "X". You can display a print preview for print lists by requesting standard function "Print".
All parameters of method SET_TABLE_FOR_FIRST_DISPLAY from global class
CL_GUI_ALV_GRID are defined in the Class Builder.
Events are defined in global class cl_gui_alv_grid; you can use these events to implement user interaction within the program. To respond to a double -click on a table line, you must respond to event DOUBLE_CLICK.
You receive control in the program, allowing you to implement interactive reporting - such as a full screen details list. The events for cl_gui_alv_grid are located in the Class Builder.
To define an implement a local class in the program, you use a handler method. In this handler method, you program the functionality to trigger by a double -click in the output table.
To activate a handler method at runtime, a class or an object from that class registers itself with an event using command SET HANDLER. The names of the IMPORTING parameters in the handler method correspond to the names of the EXPORTING parameters of the related event.
In the above example, the local class is LCL_ILS and the handler method is ON_DBLCLICK. An object - ALV_DBLCLICK - is created and registers itself for event DOUBLE_CLICK.
You can query parameter e_row-index to determine which output line was requested by the double -click. This parameter corresponds to the line number of the output table (internal table with the data records to output). If you need information for the selected line, you have to read it with READ TABLE itab INDEX e_row-index.
This subsequent read in the output table generally corresponds to the HIDE area in conventional reporting. You first have to make sure that the user has double -clicked a line in the output table (similar to the valid line selection with the HIDE technique).
A field group can contain global data objects, but not data objects that have been defined locally in a subroutine or function module.
You can use INSERT to specify both fields and field symbols. This makes it possible to dynamically insert a data object referred to by a field symbol into a field group at runtime. Any field symbols that have not been assigned are ignored, which means no new field is inserted into the field group.
The EXTRACT statement writes all the fields of a field group as one record to a sequential dataset (transport takes place with similarly named fields). If a HEADER field group is defined, then its fields are placed ahead of each record as sort keys. You can then sort the dataset with SORT and process it with LOOP ...ENDLOOP. In this case, no further EXTRACT is possible.
The INSERT statement is not a declarative statement: This means field groups can also be expanded in the program flow section.
As soon as the first dataset of a field group has been extracted with EXTRACT, that field group can no longer be expanded with INSERT. In particular, the HEADER field group cannot be expanded after the first EXTRACT (regardless of the field group).
When the GET events are processed, the logical database automatically writes hexadecimal zeros in all the fields of a node when it returns to an upper-level node in the hierarchy. Since the HEADER normally contains sort fields for all field groups, these hexadecimal zeros in the HEADER serve as a type of hierarchy key: The more zeros there are, the further up in the control level hierarchy you go.
The SORT statement sorts the extract dataset in accordance with the defined field sequence in field group HEADER. The addition BY ... sets a new sort key.
Each must be either a field of field group HEADER or a field group that consists only of fields of the field group HEADER. You can use the additions ASCENDING and DESCENDING to determine whether the fields are sorted in ascending (default) or descending order.
Fields containing X'00' in the logical databases are always displayed before all other values during a SORT.
Processing of an extract dataset always takes places within a LOOP. The contents of the extract dataset field are placed in program fields with the same names.
The group change always involves the fields of the HEADER. Single record processing for extract datasets is performed using language element AT ( = field group).
CNT() is not a statement, but instead a field that is automatically create d and filled when is a non-numeric field from field group HEADER and is part of the sort key. At the end of the group, CNT() contains the number of different values that the field recorded in this group level.
SUM() is not a statement, but instead a field that is automatically created and filled when is a numeric field of an extract dataset. At the end of the group, SUM() contains the control total of field .
*** and CNT are only available at the end of the group level or at AT LAST.
Single record processing for extract datasets AT WITH is only performed when field group is immediately followed by field group in the temporary dataset.
Loops over an extract dataset cannot be nested. However, several contiguous loops are permitted.
The sequence of the control level changes within the LOOP must correspond to the sort sequence.
Totals can only be calculated within control footer processing.
Extracts allow only appends (EXTRACT), sorting (SORT) and sequential processing (LOOP).
Once a SORT or LOOP has occurred, the intermediate dataset is frozen and cannot be expanded with EXTRACT. Operations that insert into or delete from EXTRACT datasets are not supported.
Extracts allow for several record types (FIELD-GROUPS) with fields that can be set dynamically (INSERT is not a declarative statement!). Internal tables have a single, statically-defined line type.
Internal tables use the sequence of table fields according to the declaration for the hierarchy of the control leve l. The control level structure for internal tables is therefore static, and is independent of which criteria were used to sort the internal table.
Extracts do not depend on the field sequence for control level processing: a re-sort or a completely different control level process can take place. The control level structure for extract datasets is therefore dynamic. It corresponds exactly to the sort key of the extract dataset. The sort key is the sequence of fields from the field group HEADER, and is used to sort the extract dataset.
Extracts rely on the compiler to determine which combinations of group levels and a cumulating field the control level totals desire. The desired control level totals are determined by the processing of LOOP ... ENDLOOP blocks. Internal tables build the control level total with the SUM statement.
This procedure leads to high resource depletion for totaling control levels in internal tables.
Regards,
Chandru -
Count of Sales documenst in a ALV report
Hi Gurus!
I have an ALv report that gives me a list of sales document number with other data associated with it like the material number , status , date , iem ect ect. Each docum,ent can have several line items associated with it and it shows on teh report . I have used a count column in my report which gives me the count of line items in the report . Now what I want is the count of documnet numbers in the report rather than the count of line items , which will enable to know how many sales document are ther in the report for therie r report purpose. Is ot possible to get a count of teh document numbers in the ALV report output apart from teh count of the line items . Will I ahve to make changes in my report or it can be acheived in the layout itself. Kindly advice please.
ThanksI ahve done as said
report zztest message-id zsd no standard page heading.
* For ALV usage
type-pools: slis.
data: gs_layout type slis_layout_alv,
tp_print type slis_print_alv,
gt_sort type slis_t_sortinfo_alv,
gt_events type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv with header line,
repid type syrepid, " ABAP Program.
gt_list_top_of_page type slis_t_listheader, " Top of page text.
alv_variant type disvariant. " Customize Disp. Variant
data: w_field type slis_fieldcat_alv.
data: gs_list_top_of_page type slis_listheader.
data: l_count type I.
data: l_vbeln type I.
tables: vbak, vbap, vbpa, knvv.
*DATA : v_count type N.
DATA : count1 type N.
* Definition of selection screen *
* By plant, storage location, sold-to customers, material and *
* posting date of the sales orders *
selection-screen begin of block one with frame title text-001.
parameters: p_vkorg type vkorg obligatory memory id vko,"DEVK906677
p_vtweg type vtweg obligatory default '01',
p_spart type spart obligatory default '01'.
select-options: s_vkbur for vbak-vkbur, " Sales Office "DEVK906677
s_kunnr for vbak-kunnr. " Sold-to customer number.
select-options: s_shipto for vbap-oid_ship, " Ship-to customer number.
s_billto for vbpa-kunnr, " bill-to from S.O. header.
s_load for vbpa-kunnr, " Load confirmation contact.
s_truck for vbap-oid_extbol. " Trucking ticket number.
select-options: s_werks for vbap-werks obligatory no intervals. " Plant.
select-options: s_lgort for vbap-lgort. " Storage location.
select-options: s_matnr for vbap-matnr. " Material number.
select-options: s_konda for knvv-konda. " price group
selection-screen skip 1.
select-options: s_vdatu for vbak-vdatu default sy-datum.
selection-screen end of block one.
* ALV display layout
selection-screen begin of block layout with frame title text-003.
parameters: pa_vari type slis_vari default ' '. " Display variant.
selection-screen end of block layout.
selection-screen begin of block two with frame title text-028.
selection-screen comment: /1(79) text-029.
selection-screen comment: /1(79) text-030.
selection-screen comment: /1(79) text-031.
selection-screen comment: /1(79) text-032.
selection-screen comment: /1(79) text-033.
selection-screen comment: /1(79) text-034.
selection-screen comment: /1(79) text-035.
selection-screen comment: /1(79) text-036.
selection-screen end of block two.
* Data Definitions *
* Storing Extracted Info.
types: begin of t_extract,
vbeln type vbeln_va, " Sales order number.
augru type augru, " order reason
vdatu type edatu_vbak, " Requested delivery date.
kunnr type kunag, " Sold-to customer number.
posnr type posnr_va, " Item number.
matnr type matnr, " Material number.
vrkme type vrkme, " Sales UoM.
mseh3 type mseh3, " UoM text.
netwr type netwr_ap, " Net value of the order item.
kwmeng type p length 13 decimals 1, " Quantity.
werks type werks_d, " Plant.
lgort type lgort_d, " Storage location.
oid_extbol type oid_extbol, " External BOL or truck ticker header.
maktx type maktx, " Material description.
soldto_name type name1_gp, " Sold-to name.
oid_ship type kunwe, " Ship-to customer number.
shipto_name type name1_gp, " Ship-to name.
billto type kunre, " Bill-to customer number.
billto_name type name1_gp, " Bill-to name.
load_contact type kunnr, " Load confirmation contact.
load_name type name1_gp, " Load confirmation contact name.
truck type kunnr, " Truck company number.
truck_name type name1_gp, " Truck company name.
bstkd type bstkd, " PO number.
ihrez type ihrez, " AFE number per the contract/sales order.
delivery type vbeln_vl, " Delivery number.
posnr_vl type posnr_vl, " Delivery item number.
bill_vbeln type vbeln_vf, " Invoice number.
bill_posnr type posnr_vf, " Invoice item number.
bill_netwr type netwr_fp, " Invoice net value.
statu type stats, " Document status.
auart type auart, " order type
vkorg type vkorg, " sales org.
vtweg type vtweg, " distrbtn channel
spart type spart, " division
vkbur like vbak-vkbur, " Sales Office DEVK906677
konda type konda, " price group
tdline type tdline, " text for customer account reference
count type I ,
end of t_extract.
data :
it_extract type table of t_extract with header line,
it_extract2 type table of t_extract with header line.
data: it_text type table of tline with header line.
data: w_index type sy-index,
w_tdname type tdobname.
constants: c_minus1 type netwr_ap value '1.00-'.
*RANGES: r_auart FOR vbak-auart.
data: r_auart type range of t_extract-auart,
r_auart_line like line of r_auart.
* initialization
initialization.
gs_layout-colwidth_optimize = 'X'.
tp_print-no_print_listinfos = 'X'.
tp_print-no_coverpage = 'X'.
perform set_fieldcat.
perform alv_eventtab_build using:
** Event name Form to execute Event internal table
'TOP_OF_PAGE' 'TOP_OF_PAGE' gt_events[].
* changed to exclude following order types
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZEQ'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* credit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* debit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRD'.
clear r_auart_line-high.
append r_auart_line to r_auart.
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZDR'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Industry sales order correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZSOC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield FF correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCF'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield WP correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCW'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Dropdown list for all created ALV layouts, global or user-specific
at selection-screen on value-request for pa_vari.
perform alv_variant_f4 changing pa_vari.
* Main BODY of processing logic
start-of-selection.
perform extract_data.
end-of-selection.
if not it_extract[] is initial.
* Build headings for report.
perform build_top_of_page using gt_list_top_of_page[].
perform call_alv.
endif.
*& Form EXTRACT_KEY_DATA
* Retreive the data for the report.
form extract_data.
clear: it_extract. refresh: it_extract.
* orders
select vbak~vbeln vbak~auart vbak~augru vbak~vkorg vbak~vtweg
vbak~spart vbak~vdatu vbak~kunnr vbak~vkbur
vbap~posnr vbap~matnr vbap~vrkme vbap~netwr vbap~kwmeng
vbap~werks vbap~lgort vbap~oid_extbol vbap~oid_ship
into corresponding fields of table it_extract
from vbak inner join vbap
on vbak~mandt = vbap~mandt
and vbak~vbeln = vbap~vbeln where
vbak~auart not in r_auart and
vbak~vkorg eq p_vkorg and
vbak~vtweg eq p_vtweg and
vbak~spart eq p_spart and
vbak~vkbur in s_vkbur and "DEVK906677
vbak~vdatu in s_vdatu and
vbak~kunnr in s_kunnr and
vbap~matnr in s_matnr and
vbap~werks in s_werks and
vbap~lgort in s_lgort and
vbap~oid_extbol in s_truck and
vbap~oid_ship in s_shipto.
if sy-subrc <> 0.
message i000 with text-002 ' ' ' ' ' '.
endif.
sort it_extract by vbeln.
check sy-subrc = 0.
loop at it_extract.
at new vbeln.
count1 = count1 + 1.
endat.
* Retrieve and select by load confirmation contacts from header
select single kunnr from vbpa into it_extract-load_contact
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'ZB'.
if it_extract-load_contact in s_load.
it_extract-load_name = zcl_kna1=>get_name1( it_extract-load_contact ).
else.
delete it_extract.
continue.
endif.
* Retrieve and select by sales order bill-to on header level
* as well as lookup bill-to customer name/description
select single kunnr from vbpa into it_extract-billto
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'RE'.
if sy-subrc = 0.
if s_billto is initial.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
if it_extract-billto in s_billto.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
delete it_extract.
continue.
endif.
endif.
else.
* Newalta - always has bill-to, following will not occur but included
* as good programming practice.
it_extract-billto_name = it_extract-billto.
endif.
* Retrieve and select by price group of sold-to
select single konda from knvv into it_extract-konda
where kunnr = it_extract-kunnr
and vkorg = it_extract-vkorg
and vtweg = it_extract-vtweg
and spart = it_extract-spart.
if sy-subrc = 0.
if not ( it_extract-konda in s_konda ).
delete it_extract.
continue.
endif.
endif.
* Retrieve trucking company customer
select single kunnr from vbpa into it_extract-truck where
vbeln = it_extract-vbeln and
posnr = '000000' and
parvw = 'ZT'.
if sy-subrc = 0.
it_extract-truck_name = zcl_kna1=>get_name1( it_extract-truck ).
endif.
* Retrieve sold-to name
it_extract-soldto_name = zcl_kna1=>get_name1( it_extract-kunnr ).
* Retrieve ship-to name
it_extract-shipto_name = zcl_kna1=>get_name1( it_extract-oid_ship ).
* lookup P.O.
select single bstkd ihrez from vbkd into (it_extract-bstkd, it_extract-ihrez)
where vbeln = it_extract-vbeln
and posnr = '000000'.
* Retreive the material description.
it_extract-maktx = zcl_material=>get_maktx( it_extract-matnr ).
* cosmetic change of material number, donot display leading zeros.
shift it_extract-matnr left deleting leading '0'.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
w_tdname = it_extract-vbeln.
* read customer account reference which is under 'text'
call function 'READ_TEXT'
exporting
client = sy-mandt
id = 'Z010'
language = sy-langu
name = w_tdname
object = 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
tables
lines = it_text
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8.
if sy-subrc = 0.
read table it_text index 1.
if sy-subrc = 0.
it_extract-tdline = it_text-tdline.
else.
clear it_extract-tdline.
endif.
else.
clear it_extract-tdline.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* Get the delivery item.
call method zcl_vbap=>get_delivery
EXPORTING
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
IMPORTING
etp_vbeln = it_extract-delivery
etp_posnr = it_extract-posnr_vl.
if it_extract-delivery is not initial.
perform process_deliveries.
else.
perform invoice_process.
endif.
it_extract-count = 1.
move-corresponding it_extract to it_extract2.
append it_extract2.
endloop.
describe table it_extract2 lines count1.
endform. " EXTRACT_DATA
*& Form SET_FIELDCAT
* Create the field catalogue.
form set_fieldcat .
clear w_field.
clear t_fieldcat. refresh t_fieldcat.
w_field-col_pos = 1.
w_field-fieldname = 'VBELN'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Document.Nbr'.
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 2 .
w_field-fieldname = 'POSNR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Item'(023).
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 3 .
w_field-fieldname = 'VDATU'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Req. Del. Date'(005).
append w_field to t_fieldcat.
w_field-col_pos = 4 .
w_field-fieldname = 'SOLDTO_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Sold-to'(006).
append w_field to t_fieldcat.
w_field-col_pos = 5 .
w_field-fieldname = 'MATNR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Material'(007).
append w_field to t_fieldcat.
w_field-col_pos = 6 .
w_field-fieldname = 'KWMENG'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Quantity'(008).
append w_field to t_fieldcat.
w_field-col_pos = 7.
w_field-fieldname = 'MSEH3'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'UOM'(009).
append w_field to t_fieldcat.
w_field-col_pos = 8 .
w_field-fieldname = 'BILL_VBELN'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Invoice #'(010).
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 9 .
w_field-fieldname = 'BILL_NETWR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Values'(011).
append w_field to t_fieldcat.
w_field-col_pos = 10.
w_field-fieldname = 'WERKS'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Plant'(012).
append w_field to t_fieldcat.
w_field-col_pos = 11.
w_field-fieldname = 'LGORT'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Storage Loc'(013).
append w_field to t_fieldcat.
w_field-col_pos = 12 .
w_field-fieldname = 'MAKTX'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Description'(014).
append w_field to t_fieldcat.
w_field-col_pos = 13 .
w_field-fieldname = 'SHIPTO_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Ship-to'(015).
append w_field to t_fieldcat.
w_field-col_pos = 14 .
w_field-fieldname = 'BILLTO_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Bill-to'(016).
append w_field to t_fieldcat.
w_field-col_pos = 15 .
w_field-fieldname = 'LOAD_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Load Contact'(017).
append w_field to t_fieldcat.
w_field-col_pos = 16 .
w_field-fieldname = 'TRUCK_NAME'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Truck Comp.'(018).
append w_field to t_fieldcat.
w_field-col_pos = 17 .
w_field-fieldname = 'BSTKD'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'P.O.'(019).
append w_field to t_fieldcat.
w_field-col_pos = 18 .
w_field-fieldname = 'IHREZ'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'AFE Nbr'(020).
append w_field to t_fieldcat.
w_field-col_pos = 19 .
w_field-fieldname = 'OID_EXTBOL'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Truck Ticket'(021).
append w_field to t_fieldcat.
w_field-col_pos = 20.
w_field-fieldname = 'STATU'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Status'(022).
append w_field to t_fieldcat.
w_field-col_pos = 21.
w_field-fieldname = 'AUGRU'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Ord.Reason'(024).
append w_field to t_fieldcat.
w_field-col_pos = 22.
w_field-fieldname = 'TDLINE'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'cstmr.acct.ref.'(027).
append w_field to t_fieldcat.
w_field-col_pos = 23 . "DEVK906678
w_field-fieldname = 'VKBUR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Sales Office'(037).
append w_field to t_fieldcat.
w_field-col_pos = 24.
w_field-fieldname = 'KUNNR'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Sold-to Customer'(038).
append w_field to t_fieldcat.
w_field-col_pos = 25.
w_field-fieldname = 'OID_SHIP'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Ship-to Customer'(039).
append w_field to t_fieldcat.
w_field-col_pos = 26.
w_field-fieldname = 'BILLTO'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Bill-to Customer'(040).
append w_field to t_fieldcat.
w_field-col_pos = 27.
w_field-fieldname = 'COUNT'.
w_field-tabname = IT_EXTRACT2.
w_field-seltext_l = 'Count'(041).
w_field-do_sum = 'X'.
append w_field to t_fieldcat.
endform. " SET_FIELDCAT
*& Form CALL_ALV
* Call the ALV Grid function.
form call_alv .
sort it_extract by lgort vbeln.
* repid is necessary since the ALV F.M. does not work properly with
* sy-repid.
repid = sy-repid.
alv_variant-variant = pa_vari.
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
is_variant = alv_variant
it_events = gt_events[]
is_print = tp_print
TABLES
t_outtab = IT_EXTRACT2
EXCEPTIONS
program_error = 1
others = 2.
if sy-subrc ne 0.
message w000 with text-004 ' ' ' ' ' '.
endif.
endform. " CALL_ALV
*& Form build_top_of_page
* Build heading for report. *
* -->P_GT_LIST_TOP_OF_PAGE[] Header stuff for report
form build_top_of_page using e04_lt_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader. "Header table for top of page
* construct 'top of page' info. to display. In this case, one line.
data: w_selections(40) type c,
w_date_from(10) type c,
w_date_to(10) type c.
write: s_vdatu-low to w_date_from dd/mm/yyyy.
if s_vdatu-high is not initial.
write: s_vdatu-high to w_date_to dd/mm/yyyy.
clear w_selections.
concatenate 'Del.Req.Date: ' w_date_from 'To' w_date_to
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = ' Total number of Sales Documents'.
append gs_list_top_of_page to gt_list_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = count1.
append gs_list_top_of_page to gt_list_top_of_page.
else.
clear w_date_to.
concatenate 'Del.Req.Date: ' w_date_from
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
endif.
endform. " build_top_of_page
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
form alv_eventtab_build using u_name type slis_alv_event-name
u_form type slis_alv_event-form
alv_lt_events type slis_t_event.
data: ls_event type slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
append ls_event to alv_lt_events.
endform. " alv_eventtab_build
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'LOGO'
it_list_commentary = gt_list_top_of_page.
endform. " TOP_OF_PAGE
*& Form process_deliveries
* Process the delivery related records.
form process_deliveries .
data:
ltp_date type wadat_ist, " Goods movement date.
ltp_vbtyp type vbtyp_n,
ltp_mtart type mtart, " Material type.
w_lfimg type lfimg, " Actual quantity delivered (in sales units).
w_vrkme type vrkme. " Sales unit of measure.
* Read delivery quantity and uom.
select single lfimg vrkme into (w_lfimg, w_vrkme)
from lips where
vbeln = it_extract-delivery and
posnr = it_extract-posnr_vl.
* these fields have values from vbap. override with lips values
if sy-subrc = 0.
it_extract-kwmeng = w_lfimg.
it_extract-vrkme = w_vrkme.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
endif.
* Determine STATUS by reading 'service confirmation', R (goods movemt)
* it is possible to have multiple 'service confirmation' records for
* one item. ie. delivery 80010390 in PRD.
* As long as there is at least one 'service confirmation' record,
* status is considered 'complete'.
* Validate the created on date of the goods movement or service confirmation.
ltp_mtart = zcl_material=>get_mtart( it_extract-matnr ).
* ltp_date = zcl_lips=>get_goods_movement_date( itp_vbeln = it_extract-delivery
* itp_posnr = it_extract-posnr_vl itp_mtart = ltp_mtart ).
call method zcl_lips=>get_goods_mvt_info
EXPORTING
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
itp_mtart = ltp_mtart
IMPORTING
rtp_date = ltp_date
rtp_vbtyp = ltp_vbtyp.
* 'h' is cancel goods issue
if ltp_vbtyp = 'h'.
it_extract-statu = 'Incomplete'(025).
else.
if ltp_date is not initial.
it_extract-statu = 'COMPLETE'(026).
endif.
endif.
* Retrieve the invoice/billing document item.
call method zcl_lips=>get_invoice
EXPORTING
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
IMPORTING
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
endif.
endform. " process_deliveries
*& Form user_command
* Process the user command.
* -->R_UCOMM User command
* -->RS_SELFIELD Field selected
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: ltp_vbeln type vbeln. " Sales document number.
case r_ucomm.
when '&IC1'.
if ( rs_selfield-fieldname = 'VBELN'
or rs_selfield-fieldname = 'BILL_VBELN' )
and rs_selfield-value is not initial. " Display sales document.
ltp_vbeln = rs_selfield-value.
zcl_sales_doc=>display( ltp_vbeln ).
endif.
endcase.
endform. "user_command
*& Form invoice_process
* Process for orders without deliveries. *
form invoice_process .
* Translate unit of measure.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
* Retrieve the invoice/billing document item.
call method zcl_vbap=>get_invoice
EXPORTING
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
IMPORTING
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else. " If no Invoice, then status becomes 'incomplete'.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
it_extract-statu = 'Incomplete'(025).
endif.
endform. " invoice_process
*& Form alv_variant_f4
* Get the display variant.
* <--CTP_VARI Variant name
form alv_variant_f4 changing ctp_vari type slis_vari.
alv_variant-report = sy-repid. " Report ID
alv_variant-username = sy-uname. " User ID
call function 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = alv_variant
i_save = 'A'
IMPORTING
es_variant = alv_variant
EXCEPTIONS
others = 1.
if sy-subrc = 0.
ctp_vari = alv_variant-variant.
endif.
endform. " alv_variant_f4 -
In ALV Report Filter selection should be case sensitive
Dear All,
since one field is case sensitive in database table , i have to fetch that in alv report , but when i am applying filter on that field its is simply fetching data with case description. if its in caps it should fetch caps data but in smaal case report showing no data
Regards,
Pankaj VashistaHi,
All text datas are case sensitive.
To make it work perfectly You have to Use the Keyword translate to Upper Case than display
Now filter can work.
Without Transalation to Upper Case filter will not work.
Regards
Arbind -
Column Heading are not displayed in ALV Report using CL_SALV_DISPLAY?
Hi,
I am using CL_SALV_DISPLAY class to display data. I Created an Internal Table Dynamically based fieldcatalog which was prepared based data at run time. When i displayed data using CL_SALC_DISPALY data is display in output but column headings are not displayed.
can anyone suggest me how to display heading in ALV using CL_SALV_DISPLAY class, My code is
CLASS lcl_report DEFINITION
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
METHODS:
display IMPORTING l_table TYPE string
l_fcat TYPE string.
ENDCLASS. "lcl_report DEFINITION
CLASS lcl_report IMPLEMENTATION
CLASS lcl_report IMPLEMENTATION.
METHOD display.
DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table,
ls_fcat TYPE slis_fieldcat_alv.
DATA: gr_display TYPE REF TO cl_salv_display_settings.
DATA: l_o_functions TYPE REF TO cl_salv_functions_list,
l_field TYPE string.
FIELD-SYMBOLS : <fs_table> TYPE STANDARD TABLE,
<ft_fcat> TYPE STANDARD TABLE.
Get the ALV object refering to the output table
ASSIGN (l_table) TO <fs_table>.
ASSIGN (l_fcat) TO <ft_fcat>.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
Add basic default functionality in the ALV report
Functions
l_o_functions = gr_table->get_functions( ).
l_o_functions->set_all( abap_true ).
gr_columns = gr_table->get_columns( ).
gr_columns->set_headers_visible( abap_true ).
Display the list
gr_table->display( ).
ENDMETHOD. "extract
ENDCLASS. "lcl_report IMPLEMENTATION
*& start-of-selection declaration
START-OF-SELECTION.
PERFORM :
get store codes
get_storecodes USING p_stfile
CHANGING it_t001w,
fetching mard data
read_mard_data,
preparing fieldcatalog for Final Data
create_filedcat USING it_t001w
it_site
CHANGING it_fieldcat,
preparing structure & internal table for Final Data
create_final_table_structure USING it_fieldcat,
prepare output data
prepare_final_data.
*& end-of-selection declaration
END-OF-SELECTION.
PERFORM :
display data
display_data USING l_table
l_fcat.
*& Form get_storecodes
FORM get_storecodes USING p_p_stfile
CHANGING p_it_t001w LIKE it_t001w[].
DATA :
internal table for RAW
lt_raw TYPE truxs_t_text_data,
rs_site LIKE LINE OF rt_site,
l_index LIKE sy-tabix.
FIELD-SYMBOLS :
field symbol for it_t001w
<fs_t001w> LIKE LINE OF p_it_t001w.
calling function module to get Stores Data from File
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = lt_raw
i_filename = p_p_stfile
TABLES
i_tab_converted_data = p_it_t001w[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
SORT p_it_t001w BY werks.
CLEAR rs_site.
rs_site-sign = 'I'.
rs_site-option = 'EQ'.
rs_site-low = p_dccode.
APPEND rs_site TO rt_site.
IF it_t001w[] IS NOT INITIAL.
LOOP AT p_it_t001w ASSIGNING <fs_t001w>.
l_index = sy-tabix.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <fs_t001w>-werks
IMPORTING
output = <fs_t001w>-werks.
MODIFY p_it_t001w FROM <fs_t001w> INDEX l_index.
IF <fs_t001w>-werks GE s_site-low AND <fs_t001w>-werks LE s_site-high.
append site to ranges
CLEAR rs_site.
rs_site-sign = 'I'.
rs_site-option = 'EQ'.
rs_site-low = <fs_t001w>-werks.
APPEND rs_site TO rt_site.
CONTINUE.
ENDIF.
ENDLOOP.
SORT p_it_t001w BY werks.
SORT rt_site.
ENDIF.
ENDFORM. " get_storecodes
*& Form create_final_table_structure
FORM create_filedcat USING p_it_t001w LIKE it_t001w[]
p_it_site LIKE it_site[]
CHANGING p_it_fieldcat LIKE it_fieldcat[].
FIELD-SYMBOLS :
field symbol for p_it_t001w
<fs_t001w> LIKE LINE OF p_it_t001w,
field symbol for p_it_site
<fs_site> LIKE LINE OF p_it_site.
DATA :
fieldname
l_fieldname TYPE slis_fieldname,
workarea for site ranges
rs_site LIKE LINE OF rt_site.
CLEAR : l_fieldname, rs_site.
l_fieldname = p_dccode.
PERFORM
prepare fieldcatalog
build_fieldcatalog USING : 'MTART' 'CHAR' '5' ,
'MTBEZ' 'CHAR' '25' ,
'MATKL' 'CHAR' '6' ,
'WGBEZ' 'CHAR' '20' ,
'MATNR' 'CHAR' '18' ,
'MAKTX' 'CHAR' '30' ,
l_fieldname 'CHAR' '17' .
create header for excel
PERFORM create_excel_header USING : 'Division',
'Divsion Description',
'MC Code',
'MC Description',
'Article',
'Article Description',
l_fieldname.
loop for creating fieldcatalog
LOOP AT it_site ASSIGNING <fs_site>.
READ TABLE it_t001w ASSIGNING <fs_t001w> WITH KEY werks = <fs_site>-werks
BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t001w> IS ASSIGNED AND
<fs_site> IS ASSIGNED AND <fs_site>-stock GT 0.
CLEAR : l_fieldname, rs_site.
l_fieldname = <fs_site>-werks.
prepare fieldcatalog
PERFORM build_fieldcatalog USING : l_fieldname 'CHAR' '17'.
create header for excel
PERFORM create_excel_header USING l_fieldname .
CONTINUE.
ENDIF.
ENDLOOP.
l_fcat = 'it_fieldcat[]'.
ENDFORM. " create_final_table_structure
*& Form build_fieldcatalog
FORM build_fieldcatalog USING p_fieldname TYPE slis_fieldname
p_datatype TYPE datatype_d
p_length TYPE intlen.
DATA : ls_fieldcat LIKE LINE OF it_fieldcat.
CLEAR : ls_fieldcat.
ls_fieldcat-fieldname = p_fieldname.
ls_fieldcat-datatype = p_datatype.
ls_fieldcat-intlen = p_length.
APPEND ls_fieldcat TO it_fieldcat.
ENDFORM. " build_fieldcatalog
*& Form create_final_table_structure
FORM create_final_table_structure USING p_it_fieldcat.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = t_table.
ASSIGN t_table->* TO <ft_final>.
ENDFORM. " create_final_table_structure
*& Form create_excel_header
FORM create_excel_header USING p_p_fieldname.
DATA : ls_header LIKE LINE OF it_header.
CLEAR ls_header.
ls_header-col_name = p_p_fieldname.
APPEND ls_header TO it_header.
ENDFORM. " create_excel_header
*& Form prepare_final_data
FORM prepare_final_data .
DATA : l_matnr LIKE g_matnr,
l_werks LIKE g_werks,
l_index LIKE sy-tabix.
FIELD-SYMBOLS : <fs_mard> LIKE LINE OF it_mard.
Getting No. of Lines in IT_MARD internal table
DESCRIBE TABLE it_mard LINES g_lines.
LOOP AT it_mard ASSIGNING <fs_mard>.
l_index = sy-tabix.
IF l_matnr IS INITIAL.
l_matnr = <fs_mard>-matnr.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
UNASSIGN : <fs_value>, <fs_final>.
Create dynamic work area and assign to FS
CREATE DATA t_line LIKE LINE OF <ft_final>.
ASSIGN t_line->* TO <fs_final>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mard>-matnr.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
getting Article Type,MC & its Descriptions
PERFORM get_other_data USING l_matnr
l_werks.
ELSEIF l_matnr <> <fs_mard>-matnr.
APPEND <fs_final> TO <ft_final>.
CLEAR l_matnr.
l_matnr = <fs_mard>-matnr.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
UNASSIGN : <fs_value>, <fs_final>.
Create dynamic work area and assign to FS
CREATE DATA t_line LIKE LINE OF <ft_final>.
ASSIGN t_line->* TO <fs_final>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mard>-matnr.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
getting Article Type,MC & its Descriptions
PERFORM get_other_data USING l_matnr
l_werks.
ELSE.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
ENDIF.
IF l_index = g_lines.
APPEND <fs_final> TO <ft_final>.
ENDIF.
ENDLOOP.
l_table = '<ft_final>[]'.
ENDFORM. " prepare_final_data
*& Form get_other_data
FORM get_other_data USING p_l_matnr
p_l_werks.
FIELD-SYMBOLS : <fs_mara> LIKE LINE OF it_mara,
<fs_t023t> LIKE LINE OF it_t023t,
<fs_t134t> LIKE LINE OF it_t134t,
<fs_makt> LIKE LINE OF it_makt.
READ TABLE it_mara ASSIGNING <fs_mara> WITH KEY matnr = p_l_matnr. " BINARY SEARCH.
IF sy-subrc = 0 AND <fs_mara> IS ASSIGNED.
ASSIGN COMPONENT 'MTART' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mara>-mtart.
ASSIGN COMPONENT 'MATKL' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mara>-matkl.
READ TABLE it_makt ASSIGNING <fs_makt> WITH KEY matnr = <fs_mara>-matnr BINARY SEARCH.
IF sy-subrc = 0 AND <fs_makt> IS ASSIGNED.
ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_makt>-maktx.
ENDIF.
READ TABLE it_t023t ASSIGNING <fs_t023t> WITH KEY matkl = <fs_mara>-matkl BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t023t> IS ASSIGNED.
ASSIGN COMPONENT 'WGBEZ' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_t023t>-wgbez.
ENDIF.
READ TABLE it_t134t ASSIGNING <fs_t134t> WITH KEY mtart = <fs_mara>-mtart BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t134t> IS ASSIGNED.
ASSIGN COMPONENT 'MTBEZ' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_t134t>-mtbez.
ENDIF.
ENDIF.
ENDFORM. " get_other_data
*& Form display_data
text
FORM display_data USING p_l_table
p_l_fcat.
DATA:
Variable for Object Creation
o_report TYPE REF TO lcl_report.
CREATE OBJECT o_report.
o_report->display( EXPORTING l_table = p_l_table
l_fcat = p_l_fcat ).
ENDFORM. " display_dataI don't know how to read the code you pasted or I would have checked this myself.
Do your fields in the internal table reference dictionary objects or elementary types? If not using dictionary types, the column names will be blank by default. If you can't change your fields to be dictionary types, you can try this to change the column names:
I made a method inside my local class to add the names:
call method set_colname
EXPORTING iv_tab = alv_tab
iv_colid = 'xxxx' "fieldname from the table
iv_stxt = text-t54
iv_mtxt = text-t55
iv_ltxt = text-t55.
METHOD set_colname .
data:
alv_cols type REF TO cl_salv_columns_table,
alv_col type REF TO cl_salv_column.
TRY .
*... Change fieldnames
call METHOD iv_tab->get_columns RECEIVING value = alv_cols.
call method alv_cols->get_column EXPORTING columnname = iv_colid RECEIVING value = alv_col.
IF iv_stxt <> ''.
CALL METHOD alv_col->set_short_text EXPORTING value = iv_stxt.
ENDIF.
IF iv_mtxt <> ''.
CALL METHOD alv_col->set_medium_text EXPORTING value = iv_mtxt.
ENDIF.
IF iv_ltxt <> ''.
CALL METHOD alv_col->set_long_text EXPORTING value = iv_ltxt.
ENDIF.
CATCH cx_salv_not_found.
ENDTRY.
ENDMETHOD. "set_colname -
OOP ALV report custom control performance problem
HI
how to write OOP ALV report without custom control.. Actually with custom control which taking long time... and time out happens for huge selection of data..
Regards
Roops.timeout is not an alv problem. If you try to display a "huge" amount of data, any display technology will fail. Even sap programs fail, their wise solution is to ask user to restrict data to be displayed. Or reduce database selection time, or display amount. Or propose the user to download data as a spool, or output to a file on server.
Otherwise, read some advices about how to handle timeout in [Note 25528 - Parameter rdisp/max_wprun_time|http://service.sap.com/sap/support/notes/25528].
About your question, if you still want to try, look at [example code with alv class cl_salv_table for simple display|http://help.sap.com/saphelp_nw2004s/helpdata/en/f9/1ab54099de3726e10000000a1550b0/frameset.htm] -
Jump from alv report to FB03 screen when u click BELNR field
Hi experts,
I developed one alv report in that one field is there (BELNR .When u click on BELNR field it will directly go to FB03 screen.
I wrote in this way.
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD
CASE SELFIELD-FIELDNAME.
WHEN 'BELNR'.
READ TABLE T_FINAL INDEX SELFIELD-TABINDEX.
SET PARAMETER ID 'BLN' FIELD T_FINAL-BELNR.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM.
But it is going to initial screen then u enter year it is going to next screen but i don't want this.
I want to go to directly fb03 screen without entering year in the initial screen.Is it possible? pls help me in this.IF RS_SELFIELD-FIELDNAME = 'BELNR'.
READ TABLE GT_FINAL INTO GS_FINAL INDEX RS_SELFIELD-TABINDEX.
SET PARAMETER ID 'MBN' FIELD GS_FINAL-BELNR.
CALL TRANSACTION 'MIGO' AND SKIP FIRST SCREEN.
ENDIF.
i m not getting the value of belnr in migo here is my code
Maybe you are looking for
-
Total of %db time column is greater than 100 in AWR report
Hello, I have a query regarding "To 5 timed foreground events" section of AWR report. On many occassions I found that the sum of all the values in the %db time column as mentioned above is grater than 100. How can percentage be greater than 100? Even
-
Maintenance Optimizer Error "Value loss during allocation"
Hi Everybody, like Error when Launching the Maintenance optimizer, i am facing the same problem with SolMan 7.1. Is there anything new? System is new installed. SOLMAN_SETUP is executed. BC Set for MOPZ are activeded. SMSY is arranged. MOPZ is aborti
-
Hi I would like to prepare for OCP develper track , please help me with latest dumps Thanks
-
Unable to find LogMiner Viewer in 10gR2
Hi, Am using the above Enterprise Edition on Windows XP SP2 on notebook. Am running in Archivelog mode and had supplemental log enabled. Unable to locate Start>Programs>Oracle_home>Database Administration>LogMiner Viewer as per documentation. b
-
IPad and printing with airport express
I don't have an air printer but I have a wireless printer and I'm using the airport express router, is there a way I can print from my iPad? Thanks