Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CODING EXAMPLE - LAYOUT ALV - ( very urgent )

former_member574106
Participant
0 Likes
472

Could any body please give me the coding example

where slis_layout_alv is used ? Please treat this as very urgent.

Yours sincerely,

SAURAV LAHIRY

2 REPLIES 2
Read only

Former Member
0 Likes
418

Hi Saurav,

Please check this code.

*

REPORT y56098rdup_list

NO STANDARD PAGE HEADING LINE-SIZE 240 LINE-COUNT 65(8) .

  • Declartion of Tables.

TABLES: ztril_logtable,zreasoncodes,zsdcustxref, usr21, adrp.

**************************************************************************

  • TABLES-POOLS

**************************************************************************

TYPE-POOLS: slis.

*************************************************************************

  • Internal tables declarations.

*************************************************************************

  • Declaration of output internal table

DATA: BEGIN OF tb_output OCCURS 0,

user_id TYPE xubname, " Requestor ID

role TYPE zrole, "Role

kunnr TYPE kunnr , "Customer Number 1

customer_name TYPE name1, "Customer Name

stras TYPE stras_gp, "Street Address

ort01 TYPE city, "City

regio TYPE regio, "State

pstlz TYPE pstlz, "Postal Code

land1 TYPE land1_gp, "COUNTRY CODE

po_box TYPE ad_pobx, "PO Box Number

tril_po_postal TYPE zpobox_postal, "PO BOX Postal Code

tril_err_msg TYPE zerr_message, "Error Message

reason_type TYPE zreason_type, "Reason Type

reason_code TYPE zreason_code, "Reason Code

perc_prob TYPE zprobability , "Probability Percentage

pattern_number TYPE z_pattern_no, "Match Pattern Number

country_code TYPE land1, "COUNTRY CODE

user_id_name(92) TYPE c, "UserID + Fast Name + Last Name

zlkunnr LIKE zsdcustxref-zlkunnr, "Legacy Customer NO

saplegcustno(20) TYPE c, "SAP + Legacy Customer No

reason_desc LIKE zreasoncodes-reason_desc, "Reason Description

saplegcustno1(20) TYPE c,

END OF tb_output.

  • Declation of work area.

DATA: wa_output LIKE tb_output.

  • Declaration of Internal Table.

DATA: tb_fill_output LIKE tb_output OCCURS 0 WITH HEADER LINE,

wa_fill_output LIKE tb_fill_output.

  • Declaration of internal table for ZREASONCODES

DATA: BEGIN OF tb_reasoncodes OCCURS 0.

INCLUDE STRUCTURE zreasoncodes.

DATA: END OF tb_reasoncodes.

DATA: wa_reasoncodes LIKE tb_reasoncodes.

  • Declaration of internal table ZSDCUTXREF.

DATA: BEGIN OF tb_zsdcustxref OCCURS 0,

zlkunnr LIKE zsdcustxref-zlkunnr, " Legacy Customer No

zlsourc LIKE zsdcustxref-zlsourc, " Legacy customer source code

kunnr LIKE zsdcustxref-kunnr, " Customer No

END OF tb_zsdcustxref.

  • Declation of work area.

DATA: wa_zsdcustxref LIKE tb_zsdcustxref.

  • Declaration of internal table for USR21.

DATA: BEGIN OF tb_usr21 OCCURS 0,

bname LIKE usr21-bname, " USER NAME IN USER MASTER RECORD

persnumber LIKE usr21-persnumber, " PERSON NUMBER

name_first LIKE adrp-name_first, " FIRST NAME

name_last LIKE adrp-name_last, " LAST NAME

END OF tb_usr21.

  • Declation of work area.

DATA: wa_usr21 LIKE tb_usr21.

  • Declaration of internal table for ADRP.

DATA: BEGIN OF tb_adrp OCCURS 0,

persnumber LIKE adrp-persnumber, " PERSON NUMBER

name_first LIKE adrp-name_first, " FIRST NAME

name_last LIKE adrp-name_last, " LAST NAME

END OF tb_adrp.

DATA: wa_adrp LIKE tb_adrp.

**************************************************************************

  • Declaration for fieldcatalog

**************************************************************************

DATA: tb_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv.

**************************************************************************

  • Declaration for events

**************************************************************************

DATA: tb_events TYPE slis_t_event,

wa_event TYPE slis_alv_event.

**************************************************************************

  • Declaration for Layout

**************************************************************************

DATA: tb_layout TYPE slis_layout_alv,

wb_layout TYPE slis_layout_alv.

DATA: wa_line TYPE slis_listheader,

tb_list_header TYPE slis_t_listheader.

DATA: g_date1(40) TYPE c,

g_date2(40) TYPE c,

g_date3(80) TYPE c.

**************************************************************************

  • Declaration for Selection Screen Fields

**************************************************************************

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_userid FOR ztril_logtable-user_id, "Requestor ID

s_r_type FOR zreasoncodes-reason_type, " Reason Type

s_r_code FOR zreasoncodes-reason_code

MATCHCODE OBJECT zr_code. " Reason Code

PARAMETERS : p_frmdat LIKE ztril_logtable-curr_date OBLIGATORY, " from date

p_to_dat LIKE ztril_logtable-curr_date OBLIGATORY. " to date

SELECTION-SCREEN: END OF BLOCK b1.

**************************************************************************

  • Declaration for Varialbes

**************************************************************************

DATA: g_sc_no(20) TYPE c, " To combine the SAP & Legacy Customer No

g_user_name(92) TYPE c. " To concatnate the Userid and User Name.

DATA : tb_repid LIKE trdir-name.

tb_repid = 'Y56098RDUP_LIST'.

*tb-repid type sy-repid.

DATA: BEGIN OF tb_user OCCURS 0,

user_id LIKE ztril_logtable-user_id,

END OF tb_user.

  • To get the P_USERID F4 Functionality for LOW and HIGH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_userid-low.

SELECT user_id FROM ztril_logtable INTO TABLE tb_user.

SORT tb_user.

DELETE ADJACENT DUPLICATES FROM tb_user.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'S_USERID'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'S_USERID'

value_org = 'S'

TABLES

value_tab = tb_user

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e210(zsd).

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_userid-high.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'S_USERID'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'S_USERID'

value_org = 'S'

TABLES

value_tab = tb_user

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e210(zsd).

ENDIF.

**************************************************************************

  • At selection screen event.

**************************************************************************

AT SELECTION-SCREEN.

  • Validation of User_id(USER_ID) & Reason Type(REASON_CODE)

PERFORM checking_user_id.

  • Validation of Reason type from the table ZREASONCODES

PERFORM check_reasontype.

  • Validation of Reason code from the table ZREASONCODES

PERFORM check_reasoncode.

  • Validation for checking From-Date

PERFORM checking_from_date.

  • Validation for checking To-Date

PERFORM checking_to_date.

  • Start of selection event.

START-OF-SELECTION.

  • REFRESH data & clear data.

PERFORM refresh_tables.

  • Get ZTRIL_LOGTABLE Data.

PERFORM get_tril_logtable.

  • Get data from ZREASONCODE.

PERFORM get_reasoncode_data.

  • Get the data Customer No from ZSDCUSTREF based on ZTRIL_LOGTABLE-KUNNR

PERFORM get_sdcustrefdata.

  • Get the data First Name and Last Name

PERFORM get_data_from_usr21_adrp.

  • Updateing the output internal table i.e. IT_OUTPUT data

PERFORM fill_output_data.

  • Displaying output data with two different Rows.

PERFORM output_data.

  • Populate the field catelog.

PERFORM build_fieldcatlog.

  • Declartion Events.

PERFORM event_call.

  • Top of page Information

PERFORM top_of_page.

  • Declation of Layout

PERFORM layout USING tb_layout.

  • To get the Output Format( Simple List/ ALV )

PERFORM grid_display.

.

&----


*& Form get_tril_logtable

&----


  • To get the data from table ztril_logtable

----


FORM get_tril_logtable.

REFRESH: tb_output.

  • Reading data from the table ZTRIL_LOGTABLE

SELECT user_id

role "Role

kunnr "Customer Number 1

customer_name "Customer Name

stras "Street Address

ort01 "City

regio "State

pstlz "Postal Code

land1 "COUNTRY CODE

po_box "PO Box Number

tril_po_postal "PO BOX Postal Code

tril_err_msg "Error Message

reason_type "Reason Type

reason_code "Reason Code

perc_prob

pattern_number

FROM ztril_logtable INTO

CORRESPONDING FIELDS OF

TABLE tb_output

WHERE

( curr_date GE p_frmdat AND curr_date LE p_to_dat )

  • ( curr_date BETWEEN p_frmdat AND p_to_dat )

AND

user_id IN s_userid

AND reason_code IN s_r_code

AND reason_type IN s_r_type.

IF sy-subrc NE 0.

MESSAGE i202(zsd).

ENDIF.

ENDFORM. " get_tril_logtable

&----


*& Form get_reasoncode_data

&----


  • To get the Reason code and Reason type

----


FORM get_reasoncode_data .

  • checking internal table initial data.

IF NOT tb_output[] IS INITIAL.

SELECT reason_type

reason_code

reason_desc

FROM zreasoncodes

INTO CORRESPONDING FIELDS OF TABLE tb_reasoncodes

WHERE reason_type IN s_r_type

AND reason_code IN s_r_code.

ENDIF.

ENDFORM. " get_reasoncode_data

&----


*& Form get_sdcustrefdata

&----


  • To get the legasy customer number data

----


FORM get_sdcustrefdata .

IF NOT tb_output[] IS INITIAL.

SELECT zlkunnr " Legacy Customer No

zlsourc " Legacy customer source code

kunnr " Customer No

FROM zsdcustxref INTO TABLE tb_zsdcustxref

FOR ALL ENTRIES IN tb_output

WHERE kunnr EQ tb_output-kunnr.

ENDIF.

ENDFORM. " get_sdcustrefdata

&----


*& Form fill_output_data

&----


  • To get the final data into the Internal Table

----


FORM fill_output_data .

IF NOT tb_output[] IS INITIAL.

SORT tb_output BY role user_id.

LOOP AT tb_output INTO wa_output.

READ TABLE tb_reasoncodes INTO wa_reasoncodes

WITH KEY

reason_type = wa_output-reason_type

reason_code = wa_output-reason_code BINARY SEARCH.

IF sy-subrc EQ 0.

wa_output-reason_desc = wa_reasoncodes-reason_desc.

CLEAR wa_reasoncodes.

ENDIF.

READ TABLE tb_zsdcustxref INTO wa_zsdcustxref

WITH KEY

kunnr = wa_output-kunnr.

IF sy-subrc EQ 0.

CONCATENATE wa_zsdcustxref-zlkunnr

wa_zsdcustxref-zlsourc

INTO

g_sc_no SEPARATED BY ' - '.

  • wa_output-saplegcustno1 = wa_zsdcustxref-zlkunnr.

wa_output-saplegcustno1 = g_sc_no.

ELSE.

wa_output-saplegcustno = wa_output-kunnr.

CLEAR: wa_reasoncodes,g_sc_no.

ENDIF.

READ TABLE tb_usr21 INTO wa_usr21 WITH KEY bname = wa_output-user_id.

IF sy-subrc EQ 0.

  • CONCATENATE wa_usr21-bname

CONCATENATE wa_usr21-name_first

wa_usr21-name_last

INTO

g_user_name SEPARATED BY space.

wa_output-user_id_name = g_user_name.

ENDIF.

MODIFY tb_output FROM wa_output

TRANSPORTING

reason_desc

saplegcustno

user_id_name

saplegcustno1.

CLEAR: g_user_name,wa_usr21, wa_adrp.

ENDLOOP.

ENDIF.

ENDFORM. " fill_output_data

&----


*& Form get_data_from_USR21_ADRP

&----


  • To get the first name and last name from ADRP table

----


FORM get_data_from_usr21_adrp .

IF NOT tb_output[] IS INITIAL.

SELECT bname

persnumber

FROM usr21

INTO CORRESPONDING FIELDS OF TABLE tb_usr21

FOR ALL ENTRIES IN tb_output

WHERE bname EQ tb_output-user_id.

IF NOT tb_usr21[] IS INITIAL.

SELECT persnumber

name_first

name_last

FROM adrp INTO TABLE tb_adrp

FOR ALL ENTRIES IN tb_usr21

WHERE persnumber EQ tb_usr21-persnumber.

ENDIF.

ENDIF.

LOOP AT tb_usr21 INTO wa_usr21.

READ TABLE tb_adrp INTO wa_adrp WITH KEY persnumber = wa_usr21-persnumber.

IF sy-subrc EQ 0.

wa_usr21-name_first = wa_adrp-name_first.

wa_usr21-name_last = wa_adrp-name_last.

CLEAR wa_adrp.

MODIFY tb_usr21 FROM wa_usr21 TRANSPORTING name_first name_last.

ENDIF.

ENDLOOP.

ENDFORM. " get_data_from_USR21_ADRP

&----


*& Form build_fieldcatlog

&----


  • It is used to build the fieldcatlog

----


FORM build_fieldcatlog .

wa_fieldcat-col_pos = 1.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'USER_ID'.

wa_fieldcat-seltext_l = 'Requestor ID'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 2.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'USER_ID_NAME'.

wa_fieldcat-seltext_l = 'Requestor Name'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 3.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'SAPLEGCUSTNO'.

wa_fieldcat-seltext_l = 'SAP & Legacy Customer No'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 4.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'CUSTOMER_NAME'.

wa_fieldcat-seltext_m = 'Customer Name'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 5.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'STRAS'.

wa_fieldcat-seltext_m = 'Street Address'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 6.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'ORT01'.

wa_fieldcat-seltext_m = 'City'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 7.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'REGIO'.

wa_fieldcat-seltext_m = 'State'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 8.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'PSTLZ'.

wa_fieldcat-seltext_m = 'Postal Code'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 9.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'LAND1'.

wa_fieldcat-seltext_m = 'Country Code'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 10.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'PO_BOX'.

wa_fieldcat-seltext_m = 'PO BOX NO'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 11.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'TRIL_PO_POSTAL'.

wa_fieldcat-seltext_m = 'PO Box Postal Code'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 12.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'REASON_TYPE'.

wa_fieldcat-seltext_m = 'Reason Type'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 13.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'REASON_CODE'.

wa_fieldcat-seltext_m = 'Reason Code'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 14.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'REASON_DESC'.

wa_fieldcat-seltext_m = 'Reason Description'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 15.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'PERC_PROB'.

wa_fieldcat-seltext_m = 'TOP %'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 16.

wa_fieldcat-tabname = 'TB_FILL_DATA'.

wa_fieldcat-fieldname = 'PATTERN_NUMBER'.

wa_fieldcat-seltext_m = 'Match Pattern'.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

wa_fieldcat-datatype = 'N'.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " build_fieldcatlog

&----


*& Form event_call

&----


  • It is used to call the events

----


FORM event_call .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = tb_events

EXCEPTIONS

list_type_wrong = 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. " event_call

&----


*& Form grid_display

&----


  • To display the output in ALV Grid format

----


FORM grid_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = tb_repid

  • i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = wb_layout

it_fieldcat = tb_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = tb_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

  • t_outtab = tb_output

t_outtab = tb_fill_output

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. " grid_display

&----


*& Form top_of_page

&----


  • It is used to display the Top-of-page

----


FORM top_of_page .

CLEAR: wa_line, tb_list_header[].

wa_line-typ = 'H'.

wa_line-info = 'Duplicates Ignored by Requestor Report'.

APPEND wa_line TO tb_list_header.

CLEAR wa_line.

wa_line-typ = 'S'.

WRITE p_frmdat TO g_date1 DD/MM/YY.

WRITE p_to_dat TO g_date2 DD/MM/YY.

CONCATENATE 'From Date : ' g_date1 ' To Date : ' g_date2

INTO g_date3 SEPARATED BY space .

wa_line-info = g_date3.

APPEND wa_line TO tb_list_header.

CLEAR wa_line.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = tb_list_header.

  • i_logo =

  • I_END_OF_LIST_GRID =

ENDFORM. " top_of_page

&----


*& Form layout

&----


  • It is used to display the output layout

----


FORM layout USING p_tb_layout.

tb_layout-detail_popup = 'X'.

tb_layout-colwidth_optimize = 'X'.

ENDFORM. " layout

&----


*& Form refresh_tables

&----


  • TO Refresh the internal table workarea

----


FORM refresh_tables .

REFRESH: tb_output, tb_reasoncodes, tb_zsdcustxref, tb_usr21, tb_fill_output.

CLEAR: wa_output, wa_reasoncodes, wa_zsdcustxref, wa_usr21, wa_fill_output.

ENDFORM. " refresh_tables

&----


*& Form SET_PF_STATUS

&----


  • It is used to populate the PF_STATUS

----


FORM set_pf_status USING tb_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'.

ENDFORM. " SET_PF_STATUS

&----


*& Form USER_COMMAND

&----


  • To avoid the shortdump of ALV Report

----


FORM user_command USING rf_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

ENDFORM. "user_command

&----


*& Form check_reasoncode

&----


  • Checking Reason Code

----


FORM check_reasoncode .

IF NOT s_r_type IS INITIAL.

SELECT SINGLE reason_code FROM zreasoncodes INTO s_r_code

WHERE reason_type IN s_r_type

AND reason_code IN s_r_code.

IF sy-subrc NE 0.

SET CURSOR FIELD 'S_R_CODE-LOW'.

MESSAGE e204(zsd).

ELSEIF s_r_code = 'TP'.

MESSAGE e208(zsd).

ENDIF.

ENDIF.

ENDFORM. " check_reasoncode

&----


*& Form check_reasontype

&----


  • Checking Reason Type

----


FORM check_reasontype .

IF s_r_type-low = 'TP' OR

s_r_type-high = 'TP'.

MESSAGE e208(zsd).

ENDIF.

SELECT SINGLE reason_type FROM zreasoncodes INTO s_r_type

WHERE reason_type IN s_r_type.

IF sy-subrc NE 0.

MESSAGE e201(zsd).

ENDIF.

ENDFORM. " check_reasontype

&----


*& Form checking_From_date

&----


  • Checking From Date

----


FORM checking_from_date .

SELECT SINGLE

curr_date

FROM ztril_logtable

INTO ztril_logtable-curr_date

WHERE curr_date EQ p_frmdat.

IF sy-subrc NE 0.

MESSAGE e205(zsd).

ENDIF.

ENDFORM. " checking_From_date

&----


*& Form checking_To_date

&----


  • Checking To_date

----


FORM checking_to_date .

SELECT SINGLE

curr_date

FROM ztril_logtable

INTO ztril_logtable-curr_date

WHERE curr_date EQ p_to_dat.

IF sy-subrc NE 0.

MESSAGE e206(zsd).

  • elseif p_frmdat lt p_to_dat.

  • Message e209(zsd).

ELSEIF p_frmdat GT p_to_dat.

MESSAGE e207(zsd).

ENDIF.

ENDFORM. " checking_To_date

&----


*& Form checking_user_id

&----


  • text

----


FORM checking_user_id .

SELECT SINGLE user_id

FROM ztril_logtable

INTO s_userid

WHERE user_id IN s_userid.

IF sy-subrc NE 0.

MESSAGE e200(zsd).

ENDIF.

ENDFORM. " checking_user_id

&----


*& Form output_data

&----


  • To print the Legacy customer No and SAP no into two different rows.*

----


FORM output_data .

LOOP AT tb_output INTO wa_output.

wa_fill_output-user_id = wa_output-user_id.

wa_fill_output-role = wa_output-role.

wa_fill_output-saplegcustno = wa_output-kunnr.

wa_fill_output-user_id_name = wa_output-user_id_name.

wa_fill_output-customer_name = wa_output-customer_name.

wa_fill_output-stras = wa_output-stras.

wa_fill_output-ort01 = wa_output-ort01.

wa_fill_output-regio = wa_output-regio.

wa_fill_output-pstlz = wa_output-pstlz.

wa_fill_output-land1 = wa_output-land1.

wa_fill_output-po_box = wa_output-po_box.

wa_fill_output-tril_po_postal = wa_output-tril_po_postal.

wa_fill_output-tril_err_msg = wa_output-tril_err_msg.

wa_fill_output-reason_type = wa_output-reason_type.

wa_fill_output-reason_code = wa_output-reason_code.

wa_fill_output-country_code = wa_output-country_code.

wa_fill_output-reason_desc = wa_output-reason_desc.

wa_fill_output-pattern_number = wa_output-pattern_number.

wa_fill_output-perc_prob = wa_output-perc_prob.

CLEAR: wa_output-user_id,

wa_output-role,

wa_output-kunnr,

wa_output-user_id_name,

wa_output-stras,

wa_output-ort01,

wa_output-regio,

wa_output-pstlz,

wa_output-land1,

wa_output-po_box,

wa_output-tril_po_postal,

wa_output-tril_err_msg,

wa_output-reason_type,

wa_output-reason_code,

wa_output-country_code,

wa_output-reason_desc,

wa_output-customer_name,

wa_output-pattern_number,

wa_output-perc_prob.

APPEND wa_fill_output TO tb_fill_output.

IF NOT wa_output-saplegcustno1 IS INITIAL.

CLEAR: wa_fill_output-user_id,

wa_fill_output-role,

wa_fill_output-kunnr,

wa_fill_output-user_id_name,

wa_fill_output-stras,

wa_fill_output-ort01,

wa_fill_output-regio,

wa_fill_output-pstlz,

wa_fill_output-land1,

wa_fill_output-po_box,

wa_fill_output-tril_po_postal,

wa_fill_output-tril_err_msg,

wa_fill_output-reason_type,

wa_fill_output-reason_code,

wa_fill_output-country_code,

wa_fill_output-reason_desc,

wa_fill_output-customer_name,

wa_fill_output-pattern_number,

wa_fill_output-perc_prob.

wa_fill_output-saplegcustno = wa_output-saplegcustno1.

APPEND wa_fill_output TO tb_fill_output.

CLEAR: wa_output.

ENDIF.

ENDLOOP.

ENDFORM. " output_data

Read only

Former Member
0 Likes
418

Hi

follow the code below,u can get the solution.

THIS IS TO DISPLAY THE HEADER WITH LOGO.

Follow the below step while uploading the image file:

Steps for uploading Logo :-:

1. Goto the transaction OAER

2. Enter the class name as 'PICTURES'

3. Enter the class type as 'OT'

4. Enter the object key as the name of the logo(e.g. tripodsm.gif) you wish to give

5. Execute

6. Then in the new screen select Standard doc. types in bottom window

Click on the Screen icon

Now, it will ask for the file path where you have to upload the logo

7. Now you can use this logo in REUSE_ALV_COMMENTARY_WRITE

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = i_header

i_logo = 'tripodsm.gif'.

REPORT ZCS_PRG6.

TABLES VBAK.

TYPE-POOLS SLIS.

  • Data Declaration

TYPES: BEGIN OF T_VBAK,

VBELN TYPE VBAK-VBELN,

ERDAT TYPE VBAK-ERDAT,

ERNAM TYPE VBAK-ERNAM,

AUDAT TYPE VBAK-AUDAT,

VBTYP TYPE VBAK-VBTYP,

NETWR TYPE VBAK-NETWR,

VKORG TYPE VBAK-VKORG,

VKGRP TYPE VBAK-VKGRP,

LINE_COLOR(4) TYPE C,

END OF T_VBAK.

DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,

WA_VBAK TYPE T_VBAK.

  • ALV Data Declaration

DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

GD_REPID TYPE SY-REPID.

  • I_EVENTS TYPE SLIS_T_EVENT,

  • W_EVENTS LIKE LINE OF I_EVENTS.

START-OF-SELECTION.

PERFORM DATA_RETRIEVAL.

PERFORM BLD_FLDCAT.

PERFORM BLD_LAYOUT.

PERFORM DISPLAY_ALV_REPORT.

  • Build Field Catalog for ALV Report

FORM BLD_FLDCAT.

FLDCAT-FIELDNAME = 'VBELN'.

FLDCAT-SELTEXT_M = 'Sales Document'.

FLDCAT-COL_POS = 0.

*FLDCAT-EMPHASIZE = 'C411'.

FLDCAT-OUTPUTLEN = 20.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERDAT'.

FLDCAT-SELTEXT_L = 'Record Date created'.

FLDCAT-COL_POS = 1.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERNAM'.

FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'AUDAT'.

FLDCAT-SELTEXT_M = 'Document Date'.

FLDCAT-COL_POS = 3.

FLDCAT-EMPHASIZE = 'C110'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VBTYP'.

FLDCAT-SELTEXT_L = 'SD Document category'.

FLDCAT-COL_POS = 4.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'NETWR'.

FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.

FLDCAT-COL_POS = 5.

FLDCAT-OUTPUTLEN = 60.

FLDCAT-DO_SUM = 'X'.

FLDCAT-DATATYPE = 'CURR'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKORG'.

FLDCAT-SELTEXT_L = 'Sales Organization'.

FLDCAT-COL_POS = 6.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKGRP'.

FLDCAT-SELTEXT_M = 'Sales Group'.

FLDCAT-COL_POS = 7.

FLDCAT-EMPHASIZE = 'C801'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

ENDFORM.

  • Build Layout for ALV Grid Report

FORM BLD_LAYOUT.

GD_LAYOUT-NO_INPUT = 'X'.

GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.

GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.

GD_LAYOUT-CONFIRMATION_PROMPT = 'X'. “ This asks the confirmation

before leaving the screen.

ENDFORM.

  • Display report using ALV grid

FORM DISPLAY_ALV_REPORT.

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = GD_REPID

IS_LAYOUT = GD_LAYOUT

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = 'SALES DOCUMENT HEADER'

IT_FIELDCAT = FLDCAT[]

I_SAVE = 'X'

TABLES

T_OUTTAB = IT_VBAK

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.

  • Retrieve data from VBAK table and populate itab IT_VBAK

FORM DATA_RETRIEVAL.

DATA LD_COLOR(1) TYPE C.

SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG

UP TO 20 ROWS

FROM VBAK

INTO TABLE IT_VBAK.

LOOP AT IT_VBAK INTO WA_VBAK.

LD_COLOR = LD_COLOR + 1.

IF LD_COLOR = 8.

LD_COLOR = 1.

ENDIF.

CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.

MODIFY IT_VBAK FROM WA_VBAK.

ENDLOOP.

ENDFORM.

FORM TOP_OF_PAGE.

DATA: T_HEADER TYPE SLIS_T_LISTHEADER,

W_HEADER TYPE SLIS_LISTHEADER.

W_HEADER-TYP = 'H'.

W_HEADER-INFO = 'WELCOME HEADER LIST'.

APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.

W_HEADER-KEY = 'REPORT:'.

W_HEADER-INFO = SY-REPID.

APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.

W_HEADER-KEY = 'DATE:'.

CONCATENATE SY-DATUM6(2) ' / ' SY-DATUM4(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.

APPEND W_HEADER TO T_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = T_HEADER

I_LOGO = ‘TRIPODSM.GIF’.

ENDFORM.

Reward point,if it is useful.

thanks

chandu.