Pdf and docu related to alv grid
Hi all,
Can any body please tell me how to get PDF and documents *of theory of alv grid display.* I have sample program of alv but not decent theory which can explain funcanality of function module and the parameters used in those fn module.please help me
hi,
already there is lot of material in SDn regarding everything,
the thing is u need to search in SDN.
regarding the ALV reports there is one intresting website just check in..
www.alvrobot.com.ar
Similar Messages
-
Need to add Header and footer in an alv grid display output.
How can I add header and footer in an alv grid dispay output.
For the grid display, I am using the function module "REUSE_ALV_GRID_DISPLAY".HI,
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_html_end_of_list = 'END_OF_LIST_HTML'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
DATA: ls_text TYPE sdydo_text_element,
l_grid TYPE REF TO cl_gui_alv_grid,
f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.
ls_text = 'Footer title'.
adds and icon (red triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'IL'.
adds test (via variable)
CALL METHOD end->add_text
EXPORTING
text = ls_text
sap_emphasis = 'strong'.
adds new line (start new line)
CALL METHOD end->new_line.
display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Bold text'
sap_emphasis = 'strong'.
adds new line (start new line)
CALL METHOD end->new_line.
display text(normal)
CALL METHOD end->add_text
EXPORTING
text = 'Nor'.
adds new line (start new line)
CALL METHOD end->new_line.
display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Yellow '
sap_emphasis = 'str'.
adds and icon (yellow triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'IC''.
display text(normal)
CALL METHOD end->add_text
EXPORTING
text = 'Mor'.
*set height of this section
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->parent->parent->(f)
EXPORTING
id = 3
height = 14.
ENDFORM. "end_of_list_html.
This will solve it. Post if you need more help in this.
Regards,
Madhu. -
Pack and Integer type in ALV grid
Hello,
Can anyone give a small example of how to display fields of type I and P in an ALV grid. Using the alv grid FM and manually filling the fieldcatalog.
Thanks for your help.Hi Moussa Khelifi ,
u can manually fill fieldcatalog like this..
form manual_filling_fieldcatalog.
X_FIELDCAT-FIELDNAME = 'ATWRT'.
X_FIELDCAT-TABNAME = 'TB_FINAL'.
X_FIELDCAT-SELTEXT_L = 'Source of Supply'(001).
X_FIELDCAT-DDICTXT = L_DDICTXT.
X_FIELDCAT-FIELDNAME = 'MATNR'.
X_FIELDCAT-TABNAME = 'TB_FINAL'.
X_FIELDCAT-SELTEXT_L = 'MATERIAL'(002).
X_FIELDCAT-DDICTXT = L_DDICTXT.
APPEND X_FIELDCAT TO TB_FIELDCAT .
endform.
u can directly pass the table to 'REUSE_ALV_GRID_DISPLAY'
regardless of type p or i fields in it.
Regards,
kiran B -
Query related to alv grid and sap script
Hi All,
I have a requirement where i should read the values which are selected on the alv grid list output and those values i need to display on the script(layout).
Help me out guru's its an urgency...
thanks in advance .
regards
ravi ganjiHi Ravi,
I have done it exactly like your requirement. This program contains ALV and Smartform.
But whatever may be, both are layouts and having driver program. So just finish your driver program and Script layout and then use this program.
I have written this code to print contact letters from VA42. So, modify this code to insert your transaction code.
Let me know if you have any questions.
Here is the code.
REPORT ILETTER MESSAGE-ID CM.
TYPE POOLS (ALV)
TYPE-POOLS:
slis.
Customized Types
TYPES:
BEGIN OF ty_cntrt,
box(1) TYPE c,
kunnr TYPE kunag,
vbeln TYPE vbeln_va,
vbeln1 TYPE vbeln_va,
vposn TYPE posnr,
vuntdat TYPE vudat_veda,
vbegdat TYPE vbdat_veda,
vdemdat TYPE vddat_veda,
venddat TYPE vndat_veda,
END OF ty_cntrt,
single line TYPES
BEGIN OF ty_vkorg,
vkorg TYPE vkorg,
END OF ty_vkorg.
Constants
CONSTANTS:
c_sform TYPE char10 VALUE 'SMARTFORMS',
c_tcode TYPE sy-tcode VALUE 'VA42',
c_mode TYPE c VALUE 'N',
c_updat TYPE c VALUE 'A',
c_batch TYPE sy-callr VALUE 'BATCH',
c_dclick TYPE char10 VALUE '&IC1'.
Internal tables
DATA: it_cntrt TYPE TABLE OF ty_cntrt,
it_bdc TYPE TABLE OF bdcdata,
it_mesg TYPE TABLE OF bdcmsgcoll,
it_const TYPE TABLE OF /SIE/SSG_XCM_CUC,
it_vkorg TYPE TABLE OF ty_vkorg.
Work areas
DATA: wa_cntrt TYPE ty_cntrt,
wa_bdc TYPE bdcdata,
wa_const TYPE /SIE/SSG_XCM_CUC,
w_vbak TYPE vbak,
w_veda TYPE veda,
w_xcm_pr TYPE /sie/ssg_xcm_pr,
w_vkorg TYPE ty_vkorg.
Variables
DATA: l_repid TYPE sy-repid,
l_vakey TYPE vakey,
l_variant TYPE varid-variant,
l_vbeln TYPE i,
l_vkorg TYPE i,
l_vkbur TYPE i,
l_vkgrp TYPE i,
l_ckappl(40) TYPE c,
l_ckschl(40) TYPE c,
l_cauart(40) TYPE c.
Program Constants
DATA: c_kappl TYPE kappl,
c_kschl TYPE kschl,
c_auart TYPE auart,
c_repco TYPE /sie/ssg_xcm_const,
c_value TYPE /sie/ssg_xcm_value.
ALV data declarations
DATA:
gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_tab_group TYPE slis_t_sp_group_alv,
gs_layout TYPE slis_layout_alv,
gs_repid TYPE sy-repid,
gs_sort TYPE TABLE OF slis_sortinfo_alv.
Selection screen
SELECTION-SCREEN BEGIN OF BLOCK indletter WITH FRAME TITLE text-001.
skip one line
SELECTION-SCREEN SKIP.
SELECT-OPTIONS:
contract
so_vbeln FOR w_vbak-vbeln,
category
so_auart FOR w_vbak-auart NO-DISPLAY,
Sales Org
so_vkorg FOR w_vbak-vkorg OBLIGATORY,
Dis Channel
so_vtweg FOR w_vbak-vtweg,
Division
so_spart FOR w_vbak-spart,
Sales Group
so_vkgrp FOR w_vbak-vkgrp,
Sales Office
so_vkbur FOR w_vbak-vkbur OBLIGATORY,
Cancellation Procedure
so_vkues FOR w_veda-vkuesch OBLIGATORY,
Contract Signed Date
so_vuntd FOR w_veda-vuntdat,
created by
so_ernam FOR w_vbak-ernam,
Fixed Indexation formula
so_fnum FOR w_xcm_pr-fnum OBLIGATORY.
skip one line
SELECTION-SCREEN SKIP.
Indexation letter
PARAMETERS: rb_index RADIOBUTTON GROUP radi USER-COMMAND usr.
Follow up report
PARAMETERS: rb_follo RADIOBUTTON GROUP radi.
skip one line
SELECTION-SCREEN SKIP.
Manual processing checkbox
PARAMETERS: p_manpr AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK indletter.
Printer block
SELECTION-SCREEN BEGIN OF BLOCK blk_par WITH FRAME TITLE text-002.
Printer
PARAMETERS: p_print LIKE nast-ldest DEFAULT 'LOCL' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk_par.
User selection data validation
AT SELECTION-SCREEN ON so_vkorg.
Ragne for sales org
RANGES: r_vkorg FOR vbak-vkorg.
REFRESH: it_const, r_vkorg.
CLEAR wa_const.
Proceed for execution only for Sales Orgs in /SIE/SSG_XCM_CUC
LOOP AT so_vkorg.
r_vkorg-sign = 'I'.
r_vkorg-option = 'EQ'.
r_vkorg-low = so_vkorg-low.
APPEND r_vkorg.
Check Sales Org intervals entered in the selection screen
IF NOT so_vkorg-high IS INITIAL.
Get all Sales Org for interval
SELECT vkorg FROM tvko INTO TABLE it_vkorg
WHERE vkorg BETWEEN so_vkorg-low AND so_vkorg-high.
IF sy-subrc = 0.
Add all Sales org into one internal table
LOOP AT it_vkorg INTO w_vkorg.
r_vkorg-low = w_vkorg-vkorg.
APPEND r_vkorg.
CLEAR: w_vkorg.
ENDLOOP.
delete repeated records
DELETE ADJACENT DUPLICATES FROM r_vkorg COMPARING low.
ENDIF.
ENDIF.
CLEAR r_vkorg.
ENDLOOP.
Get Sales Org entries maintained in /SIE/SSG_XCM_CUC
l_repid = sy-repid.
Check Sales Org is maintained for Renewal Letter?
LOOP AT r_vkorg.
concatenate constant with Sales Org
CONCATENATE 'INX_LETTER_CREATE_' r_vkorg-low INTO c_repco.
Get constant
SELECT SINGLE value
FROM /sie/ssg_xcm_cuc
INTO c_value
WHERE repid = l_repid
AND const = c_repco
AND vkorg EQ so_vkorg-low.
Check alerady maintained?
IF sy-subrc <> 0 OR
( sy-subrc = 0 AND c_value <> 'X' ).
Issue massage 'Sales Org no permitted for renewal Letter'.
MESSAGE E012.
CLEAR: c_repco, r_vkorg.
EXIT.
ENDIF.
CLEAR: c_repco, r_vkorg.
ENDLOOP.
AT SELECTION-SCREEN.
Read single Sales Org
READ TABLE so_vkorg INDEX 1.
IF sy-subrc = 0.
CLEAR: l_ckappl, l_ckschl, l_cauart, c_kappl, c_kschl, c_auart.
for application
CONCATENATE 'INX_LETTER_V1_' so_vkorg-low INTO l_ckappl.
for output type
CONCATENATE 'INX_LETTER_Y6C4_' so_vkorg-low INTO l_ckschl.
document type
CONCATENATE 'INX_LETTER_AUART_' so_vkorg-low INTO l_cauart.
Get application
SELECT SINGLE value FROM /sie/ssg_xcm_cuc
INTO c_kappl WHERE repid = sy-repid AND const LIKE l_ckappl.
Get output type
SELECT SINGLE value FROM /sie/ssg_xcm_cuc
INTO c_kschl WHERE repid = sy-repid AND const LIKE l_ckschl.
Get document type
SELECT SINGLE value FROM /sie/ssg_xcm_cuc
INTO c_auart WHERE repid = sy-repid AND const LIKE l_cauart.
ENDIF.
find no of Sales org entries entered in the selection screen
DESCRIBE TABLE so_vkorg LINES l_vkorg.
find no of Sales office entries entered in the selection screen
DESCRIBE TABLE so_vkbur LINES l_vkbur.
find no of Sales Group entries entered in the selection screen
DESCRIBE TABLE so_vkgrp LINES l_vkgrp.
Check if enterred more than one entry
IF l_vkorg = 1 AND l_vkbur = 1.
add Sales Org, Sales office, Sales group for key
IF NOT so_vkgrp[] IS INITIAL.
CONCATENATE so_vkorg-low so_vkbur-low so_vkgrp-low INTO l_vakey.
ELSE.
CONCATENATE so_vkorg-low so_vkbur-low '%' INTO l_vakey.
ENDIF.
CONDENSE l_vakey.
Get printer name for selection.
SELECT SINGLE ldest FROM nach INTO p_print
WHERE kappl = c_kappl AND kschl = c_kschl AND vakey LIKE l_vakey.
ENDIF.
Manual processing is possible for Renewal Letter in advance only
IF p_manpr = 'X' AND rb_follo = 'X'.
MESSAGE E017.
ENDIF.
Main Processing
START-OF-SELECTION.
Check for the Follow up report
IF rb_follo = 'X'.
Call Follow up report with Selection criteria
SUBMIT /SIE/SWE_XCM_INDEX_FOLLOWUP
USING SELECTION-SET l_variant
WITH so_vbeln IN so_vbeln
WITH so_vkorg IN so_vkorg
WITH so_vtweg IN so_vtweg
WITH so_spart IN so_spart
WITH so_vkgrp IN so_vkgrp
WITH so_vkbur IN so_vkbur
WITH so_vkues IN so_vkues
WITH so_vuntd IN so_vuntd
WITH so_ernam IN so_ernam
WITH so_fnum IN so_fnum
WITH p_kappl EQ c_kappl
WITH p_kschl EQ c_kschl
WITH p_auart EQ c_auart
AND RETURN.
ELSE.
Process for Indexation Report
gs_repid = sy-repid.
Get data.
PERFORM get_data.
Filter data based on Siemens France rules
PERFORM process_data.
Check contract data is available for selection criteria
IF NOT it_cntrt[] IS INITIAL.
create ALV output header
PERFORM alv_fieldcat USING gt_fieldcat[].
create ALV layout
PERFORM alv_layout CHANGING gs_layout.
Sort ALV output
PERFORM alv_sort.
display filtered contract data
PERFORM output_data.
ELSE.
Display a message 'No records found'.
MESSAGE I011.
EXIT.
ENDIF.
ENDIF.
*& Form get_data
Retrieve contracts data from tables
--> p1 text
<-- p2 text
FORM get_data.
Get contract data from VBAK and VEDA.
SELECT avbeln aaudat a~kunnr
bvuntdat bvbegdat
bvdemdat bvenddat
INTO CORRESPONDING FIELDS OF TABLE it_cntrt
FROM vbak AS a INNER JOIN veda AS b
ON avbeln = bvbeln
WHERE a~vbeln IN so_vbeln
AND a~auart EQ c_auart
AND a~vkorg IN so_vkorg
AND a~vtweg IN so_vtweg
AND a~spart IN so_spart
AND a~vkgrp IN so_vkgrp
AND a~vkbur IN so_vkbur
AND a~ernam IN so_ernam
AND b~vposn = '000000'
AND b~vkuesch IN so_vkues
AND b~vuntdat IN so_vuntd.
ENDFORM. " get_data
*& Form process_data
text
--> p1 text
<-- p2 text
FORM process_data.
Internal tables
DATA: l_nast TYPE TABLE OF nast,
it_pr TYPE TABLE OF /sie/ssg_xcm_pr.
Work areas
DATA: w_nast TYPE nast,
wa_pr TYPE /sie/ssg_xcm_pr.
local Variables
DATA: l_datum1 TYPE sy-datum,
l_datum2 TYPE sy-datum,
l_d3last TYPE sy-datum,
l_d3next TYPE sy-datum.
current date.
l_datum1 = sy-datum.
Calcuate date after 3 months.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_MONATE = 3
DATUM_EIN = l_datum1
IMPORTING
DATUM_AUS = l_datum2.
l_datum2 = l_datum2 - 1.
SORT it_cntrt BY KUNNR VBELN.
Get corresponding records from /SIE/SSG_XCM_PR.
SELECT vbeln posnr fnum
FROM /SIE/SSG_XCM_PR
INTO CORRESPONDING FIELDS OF TABLE it_pr
FOR ALL ENTRIES IN it_cntrt
WHERE vbeln = it_cntrt-vbeln
AND posnr = it_cntrt-vposn
AND fnum IN so_fnum.
clear workarea
CLEAR wa_cntrt.
filter contracts agaist the table /SIE/SSG_XCM_PR records.
LOOP AT it_cntrt INTO wa_cntrt.
CLEAR wa_pr.
check contracts available in table /SIE/SSG_XCM_PR
READ TABLE it_pr INTO wa_pr WITH KEY vbeln = wa_cntrt-vbeln.
IF sy-subrc <> 0.
DELETE it_cntrt.
CLEAR wa_pr.
CONTINUE.
ELSEIF sy-subrc = 0 AND NOT wa_pr-fnum IN so_fnum.
if not available, do not consider this contract
DELETE it_cntrt.
CLEAR wa_pr.
CONTINUE.
ENDIF.
Dont consider contracts expires before today and after 3 months.
IF wa_cntrt-vdemdat > l_datum1. "current date
IF wa_cntrt-vdemdat(6) > l_datum2(6). "AND "after 3 months
delete contract
DELETE it_cntrt.
CLEAR wa_cntrt.
CONTINUE.
ENDIF.
ELSE.
DELETE it_cntrt.
CLEAR wa_cntrt.
CONTINUE.
ENDIF.
Is contract renewal letter has been sent already?
Get all records from NAST to find letter sent?
SELECT kappl objky kschl nacha datvr
FROM NAST
INTO CORRESPONDING FIELDS OF TABLE l_nast
WHERE kappl = c_kappl
AND objky = wa_cntrt-vbeln
AND kschl = c_kschl
AND nacha = '1'.
IF sy-subrc = 0.
sort renewal letter sent dates by latest is first
SORT l_nast BY datvr DESCENDING.
Get latest nast record
READ TABLE l_nast INTO w_nast INDEX 1.
IF sy-subrc = 0.
IF p_manpr <> 'X'. " ignore 3 month logic
l_d3next = wa_cntrt-vdemdat(06).
l_d3next+6(2) = '01'.
Calcuate date after 3 months.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_MONATE = -3
DATUM_EIN = l_d3next
IMPORTING
DATUM_AUS = l_d3last.
l_d3last = l_d3last + 1.
Check letter already sent year equals current year
IF w_nast-datvr BETWEEN l_d3last AND wa_cntrt-vdemdat.
do not consider it
DELETE it_cntrt.
CLEAR: l_d3last, wa_cntrt, w_nast, l_d3next.
CONTINUE.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
no leading zeros to contract
WRITE wa_cntrt-vbeln TO wa_cntrt-vbeln1 NO-ZERO.
modify internal table
MODIFY it_cntrt FROM wa_cntrt.
CLEAR: l_nast, w_nast.
ENDLOOP.
ENDFORM. " process_data
*& Form output_data
text
--> p1 text
<-- p2 text
FORM output_data.
Display output in a ALV Grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gs_repid
I_CALLBACK_PF_STATUS_SET = 'ALV_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat
IT_SORT = gs_sort
I_SAVE = 'A'
TABLES
T_OUTTAB = it_cntrt
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " output_data
*& Form alv_header
text
--> p1 text
<-- p2 text
FORM alv_fieldcat USING gs_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
Sold-to Party header
ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'KUNNR'.
ls_fieldcat-seltext_m = 'Sold-to Party'.
ls_fieldcat-outputlen = 14.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO gs_fieldcat.
CLEAR ls_fieldcat.
Contract number
ls_fieldcat-col_pos = 2.
ls_fieldcat-fieldname = 'VBELN'.
ls_fieldcat-seltext_m = 'Contract Number'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-datatype = 'CHAR'.
APPEND ls_fieldcat TO gs_fieldcat.
CLEAR ls_fieldcat.
Contract Signed Date
ls_fieldcat-col_pos = 3.
ls_fieldcat-fieldname = 'VUNTDAT'.
ls_fieldcat-seltext_m = 'Contract signed date'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-datatype = 'DATS'.
APPEND ls_fieldcat TO gs_fieldcat.
CLEAR ls_fieldcat.
Contract Start Date
ls_fieldcat-col_pos = 4.
ls_fieldcat-fieldname = 'VBEGDAT'.
ls_fieldcat-seltext_m = 'Contract start date'.
ls_fieldcat-outputlen = '20'.
ls_fieldcat-datatype = 'DATS'.
APPEND ls_fieldcat TO gs_fieldcat.
CLEAR ls_fieldcat.
Dismantling date
ls_fieldcat-col_pos = 5.
ls_fieldcat-fieldname = 'VDEMDAT'.
ls_fieldcat-seltext_m = 'Dismantling date'.
ls_fieldcat-outputlen = 14.
ls_fieldcat-datatype = 'DATS'.
APPEND ls_fieldcat TO gs_fieldcat.
CLEAR ls_fieldcat.
ENDFORM. " alv_header
*& Form alv_layout
text
--> p1 text
<-- p2 text
FORM alv_layout USING ls_layout TYPE slis_layout_alv.
No input
ls_layout-no_input = 'X'.
Column width is flexible
ls_layout-colwidth_optimize = 'X'.
ls_layout-box_fieldname = 'BOX'.
ls_layout-info_fieldname = 'LINE_COLOR'.
ls_layout-zebra = 'X'.
ls_layout-get_selinfos = 'X'.
ls_layout-reprep = 'X'.
ENDFORM. " alv_layout
*& Form alv_status
text
--> p1 text
<-- p2 text
FORM alv_status USING rt_extab TYPE slis_t_extab.
GUI Status and Application Toolbar
SET PF-STATUS '/SIE/SWE_XCM_INDEXLE'.
ENDFORM.
*& Form user_command
text
--> p1 text
<-- p2 text
FORM user_command USING l_ucomm LIKE sy-ucomm
l_selfield TYPE slis_selfield.
RANGES: r_kappl FOR nast-kappl,
r_objky FOR nast-objky,
r_kschl FOR nast-kschl,
r_nacha FOR nast-nacha.
DATA: l_jobname TYPE TBTCJOB-JOBNAME,
l_jobcount TYPE TBTCJOB-JOBCOUNT,
l_repid TYPE sy-repid,
l_print_params TYPE PRI_PARAMS,
l_arc_params TYPE ARC_PARAMS,
l_valid TYPE c,
l_retcode TYPE sy-subrc,
l_blines TYPE i.
CASE l_ucomm.
Process button seleted
WHEN c_sform.
process selected records.
LOOP AT it_cntrt INTO wa_cntrt.
IF wa_cntrt-box = 'X'.
place output type in the contract
PERFORM bdc_output USING wa_cntrt
CHANGING l_retcode.
IF l_retcode = 0.
add record for jobground job
r_objky-sign = 'I'.
r_objky-option = 'EQ'.
r_objky-low = wa_cntrt-vbeln.
APPEND r_objky.
ENDIF.
CLEAR: wa_cntrt, l_retcode, r_objky.
ENDIF.
ENDLOOP.
WHEN c_dclick.
set contract number id with the selected contract
SET PARAMETER ID 'AUN' FIELD l_selfield-value.
SET PARAMETER ID 'KTN' FIELD l_selfield-value.
call va42 tcode when double click on contract
CALL TRANSACTION c_tcode AND SKIP FIRST SCREEN.
ENDCASE.
DESCRIBE TABLE r_objky LINES l_blines.
IF NOT r_objky[] IS INITIAL.
IF l_blines > 0.
Background job name.
CONCATENATE 'XCM_INDEXATION' sy-uname '_' sy-uzeit
INTO l_jobname.
Application
r_kappl-sign = 'I'.
r_kappl-option = 'EQ'.
r_kappl-low = 'V1'.
APPEND r_kappl.
Message Type
r_kschl-sign = 'I'.
r_kschl-option = 'EQ'.
r_kschl-low = c_kschl.
APPEND r_kschl.
Message transmission medium
r_nacha-sign = 'I'.
r_nacha-option = 'EQ'.
r_nacha-low = '1'.
APPEND r_nacha.
l_repid = sy-repid.
Print Parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = p_print
MODE = c_batch
NO_DIALOG = 'X'
REPORT = l_repid
EXPIRATION = 2
IMMEDIATELY = 'X'
NEW_LIST_ID = 'X'
IMPORTING
OUT_ARCHIVE_PARAMETERS = l_arc_params
OUT_PARAMETERS = l_print_params
VALID = l_valid
EXCEPTIONS
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
opening the job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = l_jobname
IMPORTING
JOBCOUNT = l_jobcount
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Job submit
SUBMIT /sie/swe_xcm_index_rsnast00 TO SAP-SPOOL
USER sy-uname
WITH s_kappl IN r_kappl
WITH s_objky IN r_objky
WITH s_kschl IN r_kschl
WITH s_nacha IN r_nacha
WITH p_print EQ p_print
VIA JOB l_jobname NUMBER l_jobcount
SPOOL PARAMETERS l_print_params
WITHOUT SPOOL DYNPRO
AND RETURN.
IF sy-subrc <> 0.
display message when error in scheduling background job
MESSAGE E016 WITH 'Error scheduling Job'.
ENDIF.
Job close
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = l_jobcount
JOBNAME = l_jobname
STRTIMMED = 'X'
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM.
*& Form bdc_output
text
--> p1 text
<-- p2 text
FORM bdc_output USING wa_cntrt TYPE ty_cntrt
CHANGING l_retcode TYPE sy-subrc.
DATA: l_nast TYPE TABLE OF nast,
it_nast TYPE TABLE OF nast,
w_nast TYPE nast,
l_cellno(2) TYPE n,
l_vbelv TYPE vbfa-vbelv,
l_vbpa TYPE vbpa,
l_yes(1),
l_temp(40) TYPE c,
l_lines TYPE i,
l_lesscnt TYPE i,
l_less(1),
l_lines1(2) TYPE n.
REFRESH: it_nast, l_nast, it_bdc.
CLEAR: l_nast, w_nast, l_yes, l_cellno,
it_nast, l_nast, it_bdc.
PERFORM dyn_scr USING 'SAPMV45A' '0102' 'X'.
PERFORM dyn_fld USING 'VBAK-VBELN' wa_cntrt-vbeln.
PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
PERFORM dyn_scr USING 'SAPMV45A' '4001' 'X'.
PERFORM dyn_fld USING 'BDC_OKCODE' '=HEAD'.
PERFORM dyn_scr USING 'SAPMV45A' '4002' 'X'.
PERFORM dyn_fld USING 'BDC_OKCODE' '=KDOK'.
SELECT *
FROM nast
INTO CORRESPONDING FIELDS OF TABLE l_nast
WHERE kappl = c_kappl
AND objky = wa_cntrt-vbeln.
IF sy-subrc = 0.
SORT l_nast BY kschl vstat.
DESCRIBE TABLE l_nast LINES l_lines.
LOOP AT l_nast INTO w_nast.
l_cellno = sy-tabix.
IF w_nast-kschl = c_kschl AND w_nast-vstat = 0.
EXIT.
ENDIF.
IF w_nast-kschl > c_kschl OR
( w_nast-kschl = c_kschl AND w_nast-vstat <> 0 ).
IF l_less = space.
l_cellno = l_cellno - 1.
ENDIF.
CLEAR l_less.
IF l_cellno = 0.
l_cellno = 1.
ENDIF.
l_lines = l_lines + 1.
l_lines1 = l_lines.
PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.
CONDENSE l_temp.
PERFORM dyn_fld USING l_temp 'Y6C4'.
CLEAR: l_temp, l_lines, l_lines1.
PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
EXIT.
ELSEIF w_nast-kschl < c_kschl.
l_less = 'X'.
l_lesscnt = l_lesscnt + 1.
ENDIF.
ENDLOOP.
ELSE.
l_cellno = '01'.
PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
CONCATENATE 'DNAST-KSCHL(' l_cellno ')' INTO l_temp.
CONDENSE l_temp.
PERFORM dyn_fld USING l_temp 'Y6C4'.
CLEAR l_temp.
PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
ENDIF.
IF l_less = 'X'.
l_lesscnt = l_lesscnt + 1.
l_cellno = l_lesscnt.
l_lines = l_lines + 1.
l_lines1 = l_lines.
PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.
CONDENSE l_temp.
PERFORM dyn_fld USING l_temp 'Y6C4'.
CLEAR: l_temp, l_lines, l_lines1.
PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
ENDIF.
PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.
CONDENSE l_temp.
PERFORM dyn_fld USING l_temp 'X'.
CLEAR l_temp.
PERFORM dyn_fld USING 'BDC_OKCODE' '=V70P'.
PERFORM dyn_scr USING 'SAPDV70A' '0101' 'X'.
PERFORM dyn_fld USING 'NAST-LDEST' p_print.
PERFORM dyn_fld USING 'NAST-DIMME' 'X'.
PERFORM dyn_fld USING 'NAST-TDARMOD' '1'.
PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.
PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.
CONDENSE l_temp.
PERFORM dyn_fld USING l_temp 'X'.
CLEAR l_temp.
PERFORM dyn_fld USING 'BDC_OKCODE' '=V70I'.
PERFORM dyn_scr USING 'SAPDV70A' '0102' 'X'.
PERFORM dyn_fld USING 'NAST-VSZTP' '1'.
PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.
PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
PERFORM dyn_fld USING 'BDC_OKCODE' '=V70S'.
CALL TRANSACTION c_tcode USING it_bdc
MODE c_mode "'N'
UPDATE c_updat "'A'
MESSAGES INTO it_mesg.
IF sy-subrc = 0.
l_retcode = 0.
ENDIF.
ENDFORM. " bdc_output
*& Form dyn_scr
text
-->P_0642 text
-->P_0643 text
-->P_0644 text
FORM dyn_scr USING P_0642
P_0643
P_0644.
MOVE: p_0642 TO wa_bdc-program,
p_0643 TO wa_bdc-dynpro,
p_0644 TO wa_bdc-dynbegin.
APPEND wa_bdc TO it_bdc.
CLEAR wa_bdc.
ENDFORM. " dyn_scr
*& Form dyn_fld
text
-->P_0654 text
-->P_0655 text
FORM dyn_fld USING P_0654
P_0655.
MOVE: p_0654 TO wa_bdc-fnam,
p_0655 TO wa_bdc-fval.
APPEND wa_bdc TO it_bdc.
CLEAR wa_bdc.
ENDFORM. " dyn_fld
*& Form alv_sort
text
FORM alv_sort.
DATA: wa_sortcat TYPE slis_sortinfo_alv.
WA_SORTCAT-SPOS = 1.
WA_SORTCAT-FIELDNAME = 'KUNNR'.
WA_SORTCAT-UP = 'X'.
WA_SORTCAT-EXPA = 'X'.
Appending gd_sortcat-tabname
APPEND WA_SORTCAT TO gs_sort.
CLEAR wa_sortcat.
WA_SORTCAT-SPOS = 2.
WA_SORTCAT-FIELDNAME = 'VBELN'.
WA_SORTCAT-UP = 'X'.
WA_SORTCAT-EXPA = 'X'.
Appending gd_sortcat-tabname
APPEND WA_SORTCAT TO gs_sort.
WA_SORTCAT-SPOS = 3.
WA_SORTCAT-FIELDNAME = 'VUNTDAT'.
WA_SORTCAT-UP = 'X'.
WA_SORTCAT-EXPA = 'X'.
Appending gd_sortcat-tabname
APPEND WA_SORTCAT TO gs_sort.
ENDFORM. " alv_sort -
Header(S) and Item(S) in ALV Grid
Hi All,
Is it possible to have multiple headers and its corresponding item details in ALV Grid Display?
The requirement is to convert the display of MB51 in ALV Grid. Is it possible in ALV Grid to have this kind of display?
Best Regards,
Kumar.Hi.
When i execute MB51,it displays in a hierarchical ALV format.
Just have a look on the following code to display the Item and
Header details.
TYPE-POOLS: SLIS.
DATA: BEGIN OF I_VBAK OCCURS 0,
VBELN LIKE VBAK-VBELN,
ERNAM LIKE VBAK-ERNAM,
ERDAT LIKE VBAK-ERDAT,
AUDAT LIKE VBAK-AUDAT,
VAR1,
END OF I_VBAK.
DATA: BEGIN OF I_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
CHARG LIKE VBAP-CHARG,
END OF I_VBAP.
DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
LAYOUT TYPE SLIS_LAYOUT_ALV,
KEY TYPE SLIS_KEYINFO_ALV.
DATA: IT_HEADER1 TYPE SLIS_T_LISTHEADER.
DATA: WA_HEADER1 TYPE SLIS_LISTHEADER.
DATA: IT_EVE1 TYPE SLIS_T_EVENT,
WA_EVE1 TYPE SLIS_ALV_EVENT.
SELECT VBELN ERNAM ERDAT AUDAT FROM VBAK
INTO CORRESPONDING FIELDS OF TABLE I_VBAK
UP TO 20 ROWS.
SELECT VBELN POSNR MATNR CHARG FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE I_VBAP
UP TO 20 ROWS.
FLDCAT-FIELDNAME = 'VBELN'.
FLDCAT-TABNAME = 'I_VBAK'.
FLDCAT-REF_FIELDNAME = 'VBELN'.
FLDCAT-REF_TABNAME = 'VBAK'.
FLDCAT-SELTEXT_M = 'SALES DOC.'.
FLDCAT-COL_POS = 0.
FLDCAT-KEY = 'X'.
APPEND FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERNAM'.
FLDCAT-TABNAME = 'I_VBAK'.
FLDCAT-REF_FIELDNAME = 'ERNAM'.
FLDCAT-REF_TABNAME = 'VBAK'.
FLDCAT-SELTEXT_M = 'NAME OF PERSON'.
FLDCAT-COL_POS = 1.
APPEND FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERDAT'.
FLDCAT-TABNAME = 'I_VBAK'.
FLDCAT-REF_FIELDNAME = 'ERDAT'.
FLDCAT-REF_TABNAME = 'VBAK'.
FLDCAT-SELTEXT_M = 'RECORD DATE'.
FLDCAT-COL_POS = 2.
APPEND FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'AUDAT'.
FLDCAT-TABNAME = 'I_VBAK'.
FLDCAT-REF_FIELDNAME = 'AUDAT'.
FLDCAT-REF_TABNAME = 'VBAK'.
FLDCAT-SELTEXT_M = 'DOCUMENT DATE'.
FLDCAT-COL_POS = 3.
APPEND FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'POSNR'.
FLDCAT-TABNAME = 'I_VBAP'.
FLDCAT-REF_FIELDNAME = 'POSNR'.
FLDCAT-REF_TABNAME = 'VBAP'.
FLDCAT-SELTEXT_M = 'SALES DOC ITEM'.
FLDCAT-COL_POS = 4.
APPEND FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'MATNR'.
FLDCAT-TABNAME = 'I_VBAP'.
FLDCAT-REF_FIELDNAME = 'MATNR'.
FLDCAT-REF_TABNAME = 'VBAP'.
FLDCAT-SELTEXT_M = 'MATERIAL NO'.
FLDCAT-COL_POS = 5.
APPEND FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'CHARG'.
FLDCAT-TABNAME = 'I_VBAP'.
FLDCAT-REF_FIELDNAME = 'CHARG'.
FLDCAT-REF_TABNAME = 'VBAP'.
FLDCAT-SELTEXT_M = 'BATCH NUMBER'.
FLDCAT-COL_POS = 6.
APPEND FLDCAT.
CLEAR FLDCAT.
LAYOUT-EXPAND_FIELDNAME = 'VAR1'.
KEY-HEADER01 = 'VBELN'.
KEY-ITEM01 = 'VBELN'.
CLEAR WA_EVE1.
WA_EVE1-NAME = 'TOP_OF_PAGE'.
WA_EVE1-FORM = 'TOP-OF-PAGE1'.
APPEND WA_EVE1 TO IT_EVE1.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FLDCAT[]
IT_EVENTS = IT_EVE1[]
I_TABNAME_HEADER = 'I_VBAK'
I_TABNAME_ITEM = 'I_VBAP'
IS_KEYINFO = KEY
TABLES
T_OUTTAB_HEADER = I_VBAK
T_OUTTAB_ITEM = I_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM TOP-OF-PAGE1. "#EC CALLED
WA_HEADER1-TYP = 'H'.
WA_HEADER1-INFO = 'Hierarchical Display'.
APPEND WA_HEADER1 TO IT_HEADER1.
CLEAR WA_HEADER1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_HEADER1[].
REFRESH IT_HEADER1.
ENDFORM. "TOP-OF-PAGE1
Regards,
Chandu. -
Validations and default Values in ALV Grid
All,
I am using "set_table_for_first_display" to display a grid with empty editable rows wherein which users can enter data and process certain transactions.
My requirement is to know if we can provide drop-downs and default values in this grid. for ex. if user want to insert a row, that row should automatically have some default values like company code, sales org etc.
Also, if there is an error while validating the data, I should be able to set the focus on that field while displaying the error message. I was able to display error message but could not set the focus on the field that need to be corrected.
Your earlier response is much appreciated.
Regards
KasiHi kasi,
check these links:
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an easy reference for alv grid control.pdf
http://www.abap4.it/download/ALV.pdf
hope this helps,
keerthi. -
Regarding subtotals and new page in ALV Grid
Hi All,
I have 5 employees in my internal table and each employee having five records.
Now iam displaying total employees in ALV grid and calculating their totals at the end of the hole records.
But i need to display the sub totals for each employee and i need new page for each employee.
means 1) New page for each employye
2) sub totals for each employee
3) grand total for all employees
How can i proceed for this requirement in ALV grid?For subtotals first you need to set the do_sum = 'X' in the fieldcatalog for the columns you want totals.
fieldcat-fieldname = 'ABC'.
fieldcat-do_sum = 'X'.
Append fieldcat to it_fieldcat,
for subtotals you need to populate the SORT table.
sort-fieldname = 'EMPLOYEE'.
sort-up = 'X'.
sort-group = '*'. "<----- this is for new page
"you can view new page in preview / print /
"if you are using the list function
sort-subtot = 'X'.
append sort to it_sort.
pass this it_sort to it_sort of the alv function. -
Up and Down Buttons in ALV Grid
Hi,
If you open the Sorting Screen of an ALV Grid, you can select Columns you want to see and you can rearange them by clicking this Up and Down Buttons. Are these up and down buttons Standard or are they only available in this Sorting Screen? Because i also want to allow the user to sort entries in an own ALV Grid by rearranging the entries with Up and Down buttons. Do i have to add them by my own or is there a standard feature. I saw that there is an Move Row Function, but i did not found any documentation on that.
Thanks,Jonhy:
This is a little example with ALV, you can see basically are tree things:
1.- Create fieldcat
2.- Have internal table with informacion
3.- CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
All buttons into ALV Tool Bar are standar, and you can hide/show them, or in some case changed a lot of behavior.
Documentation?
TAW10_3 ALV Grid control Unit, is a excelent chapter to start.
TYPE-POOLS: slis.
TABLES: SPFLI.
data: IT_SPFLI like spfli occurs 0 with header line.
data: t_fieldcat TYPE slis_t_fieldcat_alv,
fs_fieldcat LIKE LINE OF t_fieldcat.
select-options: s_carrid for spfli-carrid,
s_connid for spfli-connid.
SELECT * FROM SPFLI INTO TABLE it_spfli
where CARRID in s_carrid and
CONNID in s_connid .
fs_fieldcat-fieldname = 'CARRID'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-col_pos = 1.
fs_fieldcat-key = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat .
fs_fieldcat-fieldname = 'CONNID'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-col_pos = 2.
fs_fieldcat-key = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat .
fs_fieldcat-fieldname = 'DISTANCE'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-col_pos = 3.
fs_fieldcat-key = ' '.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
fs_fieldcat-fieldname = 'CITYFROM'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-col_pos = 4.
fs_fieldcat-key = ' '.
APPEND fs_fieldcat TO t_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IT_FIELDCAT = t_fieldcat
TABLES
t_outtab = it_spfli.
Enjoy the example.
Regards
José Luis -
Left and right justifiation in alv grid
I m using alv grid to display a tbale.I have to justify one perticular cell depending on value.So i have to first check the value of that field in itab and then justify right or left accordingly.
Therefore , i cnt use just field of field catalog as im not goin to justify whole column.
I tried to save justified value in itab and then display in alv but alv doesnt display white space charaters in start and end.
Could you help me with this topic.
regardshii,
i think this is not possible. -
Totals and Sub-Totals in ALV GRID
Could anyone advice, how to display sub-totals and totals in ALV Grid(using FM).
Ex: value1 value2
100 50
200 50
subtotal 300 100
total 400
Thanks in advance...Refer below demo code and see perform Sort_list..
it wil serve ur purpose.
REPORT ZGILL_ALV message-id rp .
type-pools slis.
tables: zgill_main,zgill_details.
data z_fieldcat type slis_t_fieldcat_alv.
data begin of itab occurs 0.
DATA ICON TYPE ICON-ID.
include structure zgill_main.
data salary like zgill_details-salary.
data end of itab.
*data itab1 like table of itab with header line.
data : WA_SORT TYPE SLIS_SORTINFO_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
PARAMETERS: p_list radiobutton group A1,
P_GRID RADIOBUTTON GROUP A1.
SELECT-OPTIONS: S_PERNR FOR ZGILL_MAIN-PERNR.
start-of-selection.
perform fill_itab.
perform sort_list.
**************Start of scenario without container******************************************
*********Method 1***********
perform fill_fieldcat. " Manuallly Preparing Fiedl Catalog
*********Method 2***********
*perform fill_fieldcat1 changing z_fieldcat. "Preparing field catalog with merge function
perform display_alv.
*****************end of scenario without container*****************************************
*& Form fill_itab
text
--> p1 text
<-- p2 text
form fill_itab .
*select * from zgill_main up to 20 rows INTO CORRESPONDING FIELDS OF TABLE itab.
*ITAB1[] = ITAB[].
select apernr aname aorg adob b~salary INTO CORRESPONDING FIELDS OF TABLE itab
from zgill_main as a join zgill_details as b on apernr = bpernr
WHERE A~PERNR IN S_PERNR.
LOOP AT ITAB.
IF ITAB-PERNR < 1111.
ITAB-ICON = '@08@'.
ELSEIF ITAB-PERNR > 1111 AND ITAB-PERNR < 11111111.
ITAB-ICON = '@09@'.
ELSEIF ITAB-PERNR GE 11111111.
ITAB-ICON = '@0A@'.
ENDIF.
MODIFY ITAB INDEX SY-TABIX.
ENDLOOP.
endform. " fill_itab
*& Form display_alv
text
--> p1 text
<-- p2 text
form display_alv .
data repid like sy-repid.
REPID = SY-REPID.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
WA_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
IF P_GRID = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_FIELDCAT = IT_FIELDTAB
IT_SORT = IT_SORT
IS_LAYOUT = WA_LAYOUT
TABLES
t_outtab = itab[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
message e016 with 'Error in Display'.
ENDIF.
ELSEIF P_LIST = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
IT_FIELDCAT = IT_FIELDTAB
IT_SORT = IT_SORT
IS_LAYOUT = WA_LAYOUT
TABLES
t_outtab = itab[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
message e016 with 'Error in Display'.
ENDIF.
ENDIF.
endform. " display_alv
*& Form fill_fieldcat1
text
--> p1 text
<-- p2 text
form fill_fieldcat1 changing d_fcat type slis_t_fieldcat_alv.
data repid like sy-repid.
data d_fcat1 type slis_t_fieldcat_alv with header line.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = repid
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME = 'ZGILL_MAIN'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = d_fcat[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF sy-subrc <> 0.
message e016 with 'Error in preparing fiedl catalog'.
ENDIF.
loop at d_fcat into d_fcat1.
case d_fcat1-fieldname.
when 'NAME'.
d_fcat1-reptext_ddic = 'Emp Name'.
MODIFY D_FCAT FROM D_FCAT1.
WHEN 'PERNR'.
d_fcat1-reptext_ddic = 'Emp Num'.
MODIFY D_FCAT FROM D_FCAT1.
WHEN 'ORG'.
d_fcat1-reptext_ddic = 'Org Unit'.
MODIFY D_FCAT FROM D_FCAT1.
endcase.
clear d_fcat1.
endloop.
endform. " fill_fieldcat1
*& Form sort_list
text
--> p1 text
<-- p2 text
form sort_list .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'DOB'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'NAME'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
endform. " sort_list
*& Form fill_fieldcat
text
--> p1 text
<-- p2 text
form fill_fieldcat .
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'ICON'.
WA_FIELDCAT-SELTEXT_L = 'TRAFFIC'.
WA_FIELDCAT-ICON = 'X'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 1.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'PERNR'.
WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 2.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
when 'maktx'.
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'NAME'.
WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.
WA_FIELDCAT-ddictxt = 'l'.
WA_FIELDCAT-COL_POS = 3.
WA_FIELDCAT-OUTPUTLEN = 15.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'ORG'.
WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.
WA_FIELDCAT-COL_POS = 4.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'DOB'.
WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.
WA_FIELDCAT-COL_POS = 5.
WA_FIELDCAT-OUTPUTLEN = 12.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-TABNAME = 'ITAB'.
WA_FIELDCAT-FIELDNAME = 'SALARY'.
WA_FIELDCAT-SELTEXT_L = 'SALARY'.
WA_FIELDCAT-COL_POS = 6.
WA_FIELDCAT-OUTPUTLEN = 25.
WA_FIELDCAT-do_sum = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDTAB.
endform. " fill_fieldcat -
How to create command button called 'Remarks' and Check box in ALV GRID?
Hi, Experts,
Requirement is: in the ALVE GRID report output, user select a record by clicking the check box and pressing the button 'Remarks' it will take me into other transaction from the output list.
Please help me out.
Reward points.
SekharHi Chandra Shekar,
Check the following sample program. 2 things to remember.
1. Check the callback subroutine PF_STATUS_SET and create PF status for the program.and also ur REMARKS button in the application tool. Comments are made every where wherever those are needed. After creating Pf status execute the report.
2.Once you select records by selecting checkboxes, u have to press on Refresh button( that is there on application toolbar), then only for selected records, CHECK field in the internal is updated. After that press on REMARKS button .
REPORT zvenkat_alv_grid.
TABLES:t001.
"Types
TYPES:
BEGIN OF t_1001,
check TYPE c,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
ort01 TYPE t001-ort01,
land1 TYPE t001-land1,
END OF t_1001.
"Work area
DATA:
w_t001 TYPE t_1001.
"Internal table
DATA:
i_t001 TYPE STANDARD TABLE OF t_1001.
" ALV Declarations
* Types Pools
TYPE-POOLS:
slis.
* Types
TYPES:
t_fieldcat TYPE slis_fieldcat_alv,
t_events TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
* Workareas
DATA:
w_fieldcat TYPE t_fieldcat,
w_events TYPE t_events,
w_layout TYPE t_layout.
* Internal Tables
DATA:
i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
i_events TYPE STANDARD TABLE OF t_events.
*& start of selection
START-OF-SELECTION.
PERFORM get_data.
*& end-of-selection.
END-OF-SELECTION.
PERFORM build_fieldcatlog.
PERFORM build_events.
PERFORM build_layout.
PERFORM list_display.
*& Form get_data
FORM get_data .
SELECT bukrs
butxt
ort01
land1
FROM t001
INTO CORRESPONDING FIELDS OF TABLE i_t001
UP TO 30 ROWS.
ENDFORM. " get_data
*& Form build_fieldcatlog
FORM build_fieldcatlog .
CLEAR:w_fieldcat,i_fieldcat[].
PERFORM build_fcatalog USING:
'CHECK' 'I_T001' ' ',
'BUKRS' 'I_T001' 'BUKRS',
'BUTXT' 'I_T001' 'BUTXT',
'ORT01' 'I_T001' 'ORT01',
'LAND1' 'I_T001' 'LAND1'.
ENDFORM. "BUILD_FIELDCATLOG
*& Form BUILD_FCATALOG
FORM build_fcatalog USING l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
IF l_field = 'CHECK'..
w_fieldcat-checkbox = 'X'.
w_fieldcat-edit = 'X'.
ENDIF.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " build_fieldcatlog
*& Form build_events
* text
FORM build_events.
CLEAR :
w_events, i_events[].
w_events-name = 'TOP_OF_PAGE'."Event Name
w_events-form = 'TOP_OF_PAGE'."Callback event subroutine
APPEND w_events TO i_events.
CLEAR w_events.
w_events-name = 'USER_COMMAND' .
w_events-form = 'USER_COMMAND' .
APPEND w_events TO i_events.
CLEAR w_events.
w_events-name = 'PF_STATUS_SET' .
w_events-form = 'PF_STATUS_SET' .
APPEND w_events TO i_events.
CLEAR w_events.
ENDFORM. "build_events
*& Form build_layout
FORM build_layout .
w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.
ENDFORM. " build_layout
*& Form list_display
FORM list_display .
DATA:
l_program TYPE sy-repid.
l_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_program
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
TABLES
t_outtab = i_t001
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " list_display
*& Form top_of_page
FORM top_of_page.
DATA :
li_header TYPE slis_t_listheader,
w_header LIKE LINE OF li_header.
DATA:
l_date TYPE char10.
WRITE sy-datum TO l_date.
w_header-typ = 'H'.
CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'S'.
w_header-info = sy-title.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'A'.
w_header-info = sy-uname.
APPEND w_header TO li_header.
CLEAR w_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = li_header.
ENDFORM. "top_of_page
*& Form pf_status_set
FORM pf_status_set USING extab TYPE slis_t_extab.
"Procedure to set own pf-status.
"1.Goto Transaction code SE41
"2.give program = SAPLKKBL and status = STANDARD_FULLSCREEN.
"3.Click on Application toolbar STATUS button
"4.Give ur program name Status name that is to be used in the program using SET pf-status statement
"5.Create ur button REMARKS.
SET PF-STATUS 'STATUS1' EXCLUDING extab.
ENDFORM. "pf_status_set
*& Form user_command
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm .
WHEN 'REMARKS'."When u click on remarks button.
LOOP AT i_t001 INTO w_t001 WHERE check = 'X'.
WRITE :/ w_t001-bukrs, 'Checked'.
ENDLOOP.
ENDCASE.
ENDFORM. "user_command
I hope that it helps u .
Regards,
Venkat.O -
How to include change delete and insert options in alv grid display
Hi,
As per my requirement I need to display my output in grid.
When the user makes any changes to any field of the alv it should get reflected in the tatabase table.
Similarly according to the requirement if user enters a new coloumn to the alv or deletes one or more rows of the alv,same should be reflected in the databse table.
I know there are many methods in object oriented.
But its little bit tough for me to implement..
Please suggest how to code for it without oo concepts.
Thanks ,
SmritiHi,
use FM with Edit functionality enabled for all fields and
Create one pf-status with some buttons
if user presses the button the alv output table should be saved and same table can be used to insert /modify /delete the dbtable.
and check this link
[alv list|alv list]
Regards,
Nandha -
Change the total and subtotal dynamically in ALV GRID
Hi guys,
I need to change the total and subtotal of field "AMOUNT" dynamically.I am using ALV GRID CONTROL(oops concept).I need to override the standard functionality.I need to show my own subtotal and total line instead of standard one .Hi
I've understood it, I wanted to use OO Grid too, but I had to use the ALV list in order to write my total.
If you need to use OO grid u can try to exclude all funcitonalities for the total, subtotal and sorting and insert in the output table the lines with your totals.
Max -
Page Up and Page Down in ALV Grid
Hello Experts,
I have a simple ALV Grid report program. . If the report displays a lot of records then the scroll ups and downs can be used. However the new requirement is to make the page up, next, prevoius, down function. I have already included a SET PF-STATUS where I copied the standard and added the page up,down,next and previous. Those buttons/icons are now active in the toolbar but its not functioning as expected, nothing happens when it is being clicked. I've read some forums and below are the propose solutions:
- Reduce the SAP work area --> how to reduce it?
- Most forums are about ALV Grid report in OO and Dialog programming whereas a code will be put in PAI and PBO to make the page up, down buttons to function. --> How will this be applied since the report is just a simple report program (not OO or dialog)
What is best solution to apply in my case?
Thanks in advance!
Best Regards,
Alezandrohi kurtt
Perhaps the below code, for scrolling the buttons can help u if the PF status and functionlity is already in place-
module scroll_tab input.
data: v_lines1 type sy-loopc.
clear: ok_code,
save_ok.
ok_code = sy-ucomm.
save_ok = ok_code.
case save_ok.
when 'PU'. "Page Up
tc1-top_line = tc1-top_line - lv_looplines.
if tc1-top_line < 1.
tc1-top_line = 1.
endif.
when 'PD'. "Page Down
tc1-top_line = tc1-top_line + lv_looplines.
if tc1-top_line > lv_lines.
tc1-top_line = ( lv_lines - lv_looplines ) + 1.
endif.
when 'PTU'. "Page total up
tc1-top_line = 1.
when 'PTD'. "Page total down
TC1-TOP_LINE = ( LV_LINES - LV_LOOPLINES ) + 1.
describe table it_vbak lines v_lines1.
tc1-top_line = v_lines1.
endcase.
endmodule. " SCROLL_TAB INPUT
regards
praveen -
Templates and document relative linking.
Im trial using DW cs5 and find that if i make a template and then
use that template to make pages it doesnt make document relative links.
Instead it makes links relative to my local drive. ie c/documents/foo.
Even if I have the template file with document relative links, when I make the page it turns into local relative and to upload this to a server wont work.
Am I missing something ?
I can figure it out.
CS4 did this fairly easy.
CheersI dont know how to fix this.
My site is set to relative document linking and the template is linked that way but when I make a new page from template it reverts to local linking.
instead of ../../ images , I get c://documents/ etc.
I dont know whats going on.
Maybe you are looking for
-
How do I change a password when email no longer exists?
I have two Adobe accounts. One of them is for my creative cloud account and the email on that account no longer exists. when I try to sign in to my creative cloud account it tells me to change the password, but the instructions for changing the pas
-
I cant upgrade using the snow leopard disc i bought any suggestions as to why this is happenning?
-
Copyright notice to all folders in Bridge CS4
Hello, everyone. I also posted this in the Bridge forum, but I think it belongs here. I entered a copyright notice in the field, under Description, and was able to copy this metadata to all the images in the same folder. I'm trying to understand how
-
Hi, Not able to stop our Solution Manager system. Os- AIX 6.1 & database-Oracle 11 Getting this error when trying to stop the instance: pm2adm> stopsap unxs0275 Checking PM2 Database Database is running stopping the SAP instance DVEBMGS10 Shutdo
-
OAF pages in different browsers--problem
Does the page behave differently on different browsers? For instance,we have a page that loads fine in mozilla, but in IE lay out goes awry. Do we have any special setting to do? Kindly reply asap