Skip to Content
author's profile photo Former Member
Former Member

screen validation

Hello everybody,

can somebody give me sample code of screen validation for multiple selction fields in alv report

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Nov 28, 2007 at 11:44 PM

    http://www.sap-basis-abap.com/abap/alv-example-contract-renewal-details.htm

    ALV Example: Contract Renewal Details

    Tips by: M. Praveen Kumar

    ----


    • Contract Renewal Details *

    ----


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

    • Description: The contract details of the customers in a particular *

    • sales area are displayed. This report is run to view the *

    • * contract details existing *

    • Author : M.Praveen kumar *

    • Date : 18 March 2005 *

    • *

    ----


    • Change No | Date | Details | Req No *

    ----


    • CR-102 | 18/03/05 | Original Version | PRDK90011*

    • | | | *

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

    REPORT zadi_sd_contractalv NO STANDARD PAGE HEADING

    LINE-COUNT 45(2) LINE-SIZE 130

    MESSAGE-ID ymessage.

    *********************Type Pool Declaration for ALV*******************

    TYPE-POOLS: slis.

    *******************Table Declaration*********************************

    TABLES: vbak,vbfa,veda.

    ********************Declaring Data Objects***************************

    DATA: BEGIN OF lt_sd_c1 OCCURS 0,

    vbeln LIKE vbak-vbeln, "Sales Document Number

    vbelv LIKE vbfa-vbelv, "Preceding Sales and Distribution Doc

    kunnr LIKE vbak-kunnr, "Customer Number

    END OF lt_sd_c1.

    *data: Lt_Sd_C2 like veda occurs 0 with header line.

    DATA: gt_fieldcat TYPE slis_t_fieldcat_alv, "ALV Catalog Table

    gs_fieldcat TYPE slis_fieldcat_alv. "ALV Catalog Structure

    DATA: BEGIN OF lt_sd_c2 OCCURS 0,

    vbeln LIKE veda-vbeln, "Sales Document Number

    vlaufz LIKE veda-vlaufz, "Validity Period of Contract

    vuntdat LIKE veda-vuntdat, "Date on which Contract was Signed

    vbegdat LIKE veda-vbegdat, "Contract Start Date

    venddat LIKE veda-venddat, "Contract End Date

    END OF lt_sd_c2.

    ****************************Selection Screen**************************

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

    SELECT-OPTIONS: s_vkorg FOR vbak-vkorg OBLIGATORY,"Sales organization.

    s_vtweg FOR vbak-vtweg, "Distribution channel.

    s_spart FOR vbak-spart, "Division.

    s_kunnr FOR vbak-kunnr, "Customer number

    p_dat FOR sy-datum."Date=current date

    SELECTION-SCREEN END OF BLOCK b1.

    SELECTION-SCREEN BEGIN OF BLOCK c1 WITH FRAME TITLE text-100.

    PARAMETERS list RADIOBUTTON GROUP radi.

    PARAMETERS alv RADIOBUTTON GROUP radi.

    SELECTION-SCREEN END OF BLOCK c1.

    ****************Validation of Selection Screen Fields*****************

    AT SELECTION-SCREEN.

    SELECT SINGLE vkorg FROM tvko INTO vbak-vkorg WHERE vkorg IN s_vkorg.

    IF sy-subrc <> 0.

    MESSAGE e002.

    ENDIF.

    SELECT SINGLE vtweg FROM tvkov INTO vbak-vtweg WHERE vtweg IN s_vtweg.

    IF sy-subrc <> 0.

    MESSAGE e004.

    ENDIF.

    SELECT SINGLE spart FROM tspa INTO vbak-spart WHERE spart IN s_spart.

    IF sy-subrc <> 0.

    MESSAGE e006.

    ENDIF.

    SELECT SINGLE kunnr FROM kna1 INTO vbak-kunnr WHERE kunnr IN s_kunnr.

    IF sy-subrc <> 0.

    MESSAGE e007.

    ENDIF.

    ********************************Data Fetching*************************

    START-OF-SELECTION.

    SELECT avbeln akunnr b~vbelv

    FROM vbak AS a INNER JOIN vbfa AS b

    ON avbeln = bvbeln

    INTO CORRESPONDING FIELDS OF TABLE lt_sd_c1

    WHERE vkorg IN s_vkorg

    AND vtweg IN s_vtweg

    AND spart IN s_spart

    AND kunnr IN s_kunnr.

    IF NOT lt_sd_c1[] IS INITIAL.

    SELECT vbeln vlaufz vuntdat vbegdat venddat

    FROM veda INTO CORRESPONDING FIELDS OF TABLE lt_sd_c2

    FOR ALL ENTRIES IN lt_sd_c1

    WHERE vbeln = lt_sd_c1-vbelv

    AND venddat = p_dat.

    ELSE.

    MESSAGE i005.

    EXIT.

    ENDIF.

    END-OF-SELECTION.

    ******************************Display of Data*************************

    IF list = 'X'.

    LOOP AT lt_sd_c2.

    WRITE:/0 sy-vline,

    lt_sd_c2-vbeln UNDER 'SALES DOCUMENT', 16 sy-vline,

    lt_sd_c2-vuntdat UNDER 'CONTRACT SINGED DATE', 42 sy-vline,

    lt_sd_c2-vbegdat UNDER 'CONTRACT START DATE', 65 sy-vline,

    lt_sd_c2-venddat UNDER 'CONTRACT END DATE' COLOR 6, 100 sy-vline,

    lt_sd_c2-vlaufz UNDER 'VALIDITY PERIOD OF CONTRACT', 130 sy-vline.

    ENDLOOP.

    ULINE.

    ELSE.

    *************Calling a subroutine for Field display in ALV************

    PERFORM built_field_catalog.

    ************Calling fucntion module for ALV***************************

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_background_id = 'ALV_BACKGROUND'

    i_grid_title = 'Contract Details'

    • i_structure_name = 'veda'

    it_fieldcat = gt_fieldcat[]

    TABLES

    t_outtab = lt_sd_c2.

    ENDIF.

    *************************Header for the page**************************

    TOP-OF-PAGE.

    WRITE:/ 'CREATED BY : ', sy-uname,

    102 'CREATED ON :', sy-datum,

    /1(130) sy-uline .

    WRITE:/ sy-vline, 50 ' CONTRACT DETAILS ' COLOR 5,

    111 'Page No:',

    sy-pagno,

    130 sy-vline.

    ULINE.

    WRITE:/0 sy-vline,

    2 'SALES DOCUMENT' COLOR 3,16 sy-vline,

    20 'CONTRACT SIGNED DATE' COLOR 3, 42 sy-vline,

    45 'CONTRACT START DATE' COLOR 3, 65 sy-vline,

    75 'CONTRACT END DATE' COLOR 3, 100 sy-vline,

    102 'VALIDITY PERIOD OF CONTRACT' COLOR 3, 130 sy-vline.

    ULINE.

    &----


    *& Form built_field_catalog

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM built_field_catalog.

    gs_fieldcat-col_pos = '1'.

    gs_fieldcat-fieldname = 'VBELN'.

    gs_fieldcat-outputlen = 30.

    gs_fieldcat-seltext_l = 'SALES DOCUMENT NUMBER'.

    APPEND gs_fieldcat TO gt_fieldcat.

    gs_fieldcat-col_pos = '2'.

    gs_fieldcat-fieldname = 'VLAUFZ'.

    gs_fieldcat-outputlen = 9.

    gs_fieldcat-seltext_l = 'VALIDITY'.

    APPEND gs_fieldcat TO gt_fieldcat.

    gs_fieldcat-col_pos = '3'.

    gs_fieldcat-fieldname = 'VUNTDAT'.

    gs_fieldcat-outputlen = 12.

    gs_fieldcat-seltext_l = 'SIGNED DATE'.

    APPEND gs_fieldcat TO gt_fieldcat.

    gs_fieldcat-col_pos = '4'.

    gs_fieldcat-fieldname = 'VBEGDAT'.

    gs_fieldcat-outputlen = 12.

    gs_fieldcat-seltext_l = 'START DATE'.

    APPEND gs_fieldcat TO gt_fieldcat.

    gs_fieldcat-col_pos = '5'.

    gs_fieldcat-fieldname = 'VENDDAT'.

    gs_fieldcat-outputlen = 12.

    gs_fieldcat-seltext_l = 'END DATE'.

    APPEND gs_fieldcat TO gt_fieldcat.

    ENDFORM.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 05:49 AM

    HI Priya ,

    see this report you can understand very easily

    alomost all some nice fetures available in this report , if you want i can explain and see that bold one which is for validation

    REPORT ZNNR_REPORT NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 100 LINE-COUNT 65(4).

    ******DATA DECLARATIONS**********

    DATA : BEGIN OF IT_PLANT OCCURS 0,

    MATNR LIKE MARA-MATNR,

    WERKS LIKE MARC-WERKS,

    PSTAT LIKE MARC-PSTAT,

    EKGRP LIKE MARC-EKGRP,

    END OF IT_PLANT.

    DATA : BEGIN OF IT_PONO OCCURS 0,

    EBELN LIKE EKKO-EBELN,

    EBELP LIKE EKPO-EBELP,

    MATNR LIKE EKPO-MATNR,

    WERKS LIKE EKPO-WERKS,

    LGORT LIKE EKPO-LGORT,

    END OF IT_PONO.

    TABLES EKKO.

    ********END OF DATA DECLARATIONS*********

    ********SELECTION SCREEN DESIGN ***********

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.

    SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

    SELECTION-SCREEN END OF BLOCK B1.

    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

    SELECTION-SCREEN BEGIN OF LINE.

    PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.

    SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN BEGIN OF LINE.

    PARAMETERS : R2 RADIOBUTTON GROUP G1.

    SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN END OF BLOCK B2.

    ******END OF SELECTION SCREEN DESIGN****************

    *********INITIALIZATION OF SELECTION SCREEN ELEMENTS.*****

    INITIALIZATION.

    P_WERKS = '1000'.

    S_EBELN-LOW = '4500016926'.

    S_EBELN-OPTION = 'EQ'.

    S_EBELN-SIGN = 'I'.

    APPEND S_EBELN.

    CLEAR S_EBELN.

    ************END OF INITIALIZATION***********************

    ***********SCREEN MODIFICATIONS*******************

    AT SELECTION-SCREEN OUTPUT.

    LOOP AT SCREEN.

    IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.

    SCREEN-INPUT = 0.

    MODIFY SCREEN.

    ENDIF.

    IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.

    SCREEN-INPUT = 0.

    MODIFY SCREEN.

    ENDIF.

    ENDLOOP.

    ********END OF SCREEN MODIFICATIONS*****************

    <b>***************SCREEN VALIDATIONS *****************

    at selection-screen.

    SELECT SINGLE *

    FROM EKKO

    INTO EKKO

    WHERE EBELN IN S_EBELN.

    IF SY-SUBRC <> 0.

    SET CURSOR FIELD 'S_EBELN-LOW'.

    MESSAGE E999 WITH TEXT-005.

    ENDIF.

    ********end of screen validation*****************</b>

    START-OF-SELECTION.

    *set pf-status '100'.

    IF R1 EQ 'X'.

    SELECT MATNR

    WERKS

    PSTAT

    EKGRP

    FROM MARC

    INTO TABLE IT_PLANT

    WHERE WERKS = P_WERKS.

    LOOP AT IT_PLANT.

    WRITE : SY-VLINE , 2 IT_PLANT-MATNR COLOR COL_KEY,

    21 SY-VLINE , 22 IT_PLANT-WERKS COLOR COL_KEY,

    27 SY-VLINE ,28 IT_PLANT-PSTAT COLOR COL_NORMAL,

    43 SY-VLINE ,44 IT_PLANT-EKGRP COLOR COL_NORMAL.

    ENDLOOP.

    ENDIF.

    IF R2 EQ 'X'.

    SELECT EBELN EBELP MATNR WERKS LGORT

    FROM EKPO

    INTO TABLE IT_PONO

    WHERE EBELN IN S_EBELN.

    LOOP AT IT_PONO.

    WRITE : SY-VLINE , 2 IT_PONO-EBELN COLOR COL_KEY,

    12 SY-VLINE , 13 IT_PONO-EBELP COLOR COL_KEY,

    18 SY-VLINE , 19 IT_PONO-MATNR COLOR COL_NORMAL,

    37 SY-VLINE , 38 IT_PONO-WERKS COLOR COL_NORMAL,

    44 SY-VLINE , 45 IT_PONO-LGORT COLOR COL_NORMAL, 49 SY-VLINE..

    ENDLOOP.

    ENDIF.

    TOP-OF-PAGE.

    IF R1 EQ 'X'.

    *ULINE AT /1(48).

    WRITE : SY-VLINE ,2 'MATERIAL NUMBER',

    21 SY-VLINE , 22 'PLANT',

    27 SY-VLINE , 28 'STATUS',

    43 SY-VLINE , 44 'GRUP', 48 SY-VLINE.

    ULINE AT /1(48).

    ENDIF.

    IF R2 EQ 'X'.

    WRITE : SY-VLINE , 2 'PO NUMBER',

    12 SY-VLINE, 13 'ITEM',

    18 SY-VLINE,19 'MATERIAL NUMBER',

    37 SY-VLINE, 38 'PLANT',

    44 SY-VLINE, 45 'GRUP',

    49 SY-VLINE.

    ULINE AT /1(50).

    ENDIF.

    END-OF-PAGE.

    ULINE AT /1(50).

    WRITE :/10 'PAGE NUMBER', SY-PAGNO.

    <b>Reward if usefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 08:27 AM

    &----


    *& Report ZFLOC

    *&

    &----


    *&

    *&

    &----


    REPORT zfloc message-id zfloc.

    TABLES : iflot.

    --


    global data declerations--

    DATA: ok_code LIKE sy-ucomm,

    out_tab2 TYPE TABLE OF zalv ,

    --


    Name of the custom control aded on the screen.--

    g_container TYPE scrfname VALUE 'FUNC_LOC',

    flocgrid TYPE REF TO cl_gui_alv_grid,

    --


    Custom container instance reference--

    g_floc_container TYPE REF TO cl_gui_custom_container,

    e_row TYPE lvc_s_row,

    e_column TYPE lvc_s_col,

    e_row_number TYPE lvc_s_roid,

    o_dyndoc_id TYPE REF TO cl_dd_document.

    --


    CLASS zcl_floc DEFINITION--

    CLASS zcl_floc DEFINITION.

    PUBLIC SECTION.

    CLASS-METHODS : handle_double_click

    FOR EVENT double_click OF cl_gui_alv_grid

    IMPORTING e_row e_column ,

    handle_print_top_of_list

    FOR EVENT print_top_of_list OF cl_gui_alv_grid.

    ENDCLASS. "zcl_floc DEFINITION

    --


    CLASS zcl_floc IMPLEMENTATION--

    CLASS zcl_floc IMPLEMENTATION.

    METHOD handle_double_click.

    PERFORM handle_double_click USING e_row e_column e_row_number.

    ENDMETHOD. "handle_double_click

    METHOD handle_print_top_of_list.

    PERFORM top_of_page.

    ENDMETHOD. "handle_print_top_of_list

    ENDCLASS. "zcl_floc IMPLEMENTATION

    --


    SELECTION-SCREEN DESIGN--

    *SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.

    *SELECT-OPTIONS: s_fltyp FOR iflot-fltyp NO-EXTENSION ,

    • s_tplnr FOR iflot-tplnr NO-EXTENSION OBLIGATORY ,

    • s_objnr FOR iflot-objnr NO-EXTENSION.

    *SELECTION-SCREEN END OF BLOCK b1.

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

    PARAMETERS: s_fltyp LIKE iflot-fltyp ,

    s_tplnr LIKE iflot-tplnr OBLIGATORY ,

    s_objnr LIKE iflot-objnr .

    SELECTION-SCREEN END OF BLOCK b1.

    --


    IMPLEMENTATION OF AT-SELECTION-SCREEN EVENT--

    AT SELECTION-SCREEN .

    SELECT

    tplnr INTO iflot FROM iflot WHERE tplnr EQ s_tplnr.

    ENDSELECT.

    IF sy-subrc NE 0.

    MESSAGE E001 .

    ENDIF.

    SELECT

    fltyp INTO iflot FROM iflot WHERE fltyp EQ s_fltyp.

    ENDSELECT.

    IF sy-subrc NE 0.

    MESSAGE E002 .

    ENDIF.

    SELECT

    objnr INTO iflot FROM iflot WHERE objnr EQ s_objnr.

    ENDSELECT.

    IF sy-subrc NE 0.

    MESSAGE E003.

    ENDIF.

    --


    IMPLEMENTATION OF START-OF-SELECTION EVENT--

    START-OF-SELECTION.

    PERFORM fetchdata.

    END-OF-SELECTION.

    --


    CALLING SCREEN IN WHICH THE OUTPUT IS DISPLAYED--

    CALL SCREEN 100.

    &----


    *& Form FETCHDATA

    &----


    • text

    ----


    FORM fetchdata.

    • SELECT i~tplnr

    • f~pltxt

    • i~invnr

    • i~objnr

    • i~erdat

    • i~fltyp

    • i~iwerk

    • a~class

    • k~clint

    • c~atnam

    • c~atinn

    • w~atwrt

    • t~atwtb

    • b~atbez

  • INTO CORRESPONDING FIELDS OF TABLE out_tab2

  • FROM ( ( ( iflot AS i INNER JOIN iflo AS f ON ftplnr = itplnr )

  • INNER JOIN kssk AS k ON kobjek = itplnr )

  • INNER JOIN klah AS a ON aclint = kclint )

    • INNER JOIN cabn AS c ON cclint = kclint )

    • INNER JOIN cawn AS w ON watinn = catinn )

    • INNER JOIN cawnt AS t ON tatinn = catinn )

    • INNER JOIN cabnt AS b ON batinn = catinn )

  • WHERE itplnr IN s_tplnr AND ifltyp IN s_fltyp AND i~objnr IN s_objnr.

  • *

    • IF sy-subrc NE 0.

    • MESSAGE E004.

    • LEAVE PROGRAM.

    • ENDIF.

    CALL FUNCTION 'ZBAPI_FLOC_GETDETAIL'

    EXPORTING

    tplnr = s_tplnr

    FLTYP = s_FLTYP

    OBJNR = s_OBJNR

    TABLES

    output = out_tab2

    .

    ENDFORM. "FETCHDATA

    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • text

    ----


    MODULE status_0100 OUTPUT.

    SET PF-STATUS 'FLOC'.

    SET TITLEBAR '100'.

    IF g_floc_container IS INITIAL.

    --


    CREATING CUSTOM CONTAINER INSTANCE--

    CREATE OBJECT g_floc_container

    EXPORTING container_name = g_container.

    CREATE OBJECT o_dyndoc_id

    EXPORTING style = 'ALV_GRID'.

    --


    CREATING ALV GRID INSTANCE--

    CREATE OBJECT flocgrid

    EXPORTING i_parent = g_floc_container.

    CALL METHOD flocgrid->set_table_for_first_display

    EXPORTING

    i_structure_name = 'ZALV'

    CHANGING

    it_outtab = out_tab2.

    CALL METHOD flocgrid->refresh_table_display

    EXCEPTIONS

    finished = 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.

    --


    SET EVENT HANDLERS--

    SET HANDLER zcl_floc=>handle_double_click FOR flocgrid.

    SET HANDLER zcl_floc=>handle_print_top_of_list FOR flocgrid.

    ENDIF.

    ENDMODULE. " STATUS_0100 OUTPUT

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • text

    ----


    MODULE user_command_0100 INPUT.

    CASE ok_code.

    WHEN 'EXIT'.

    LEAVE PROGRAM.

    ENDCASE.

    CLEAR ok_code.

    ENDMODULE. " USER_COMMAND_0100 INPUT

    &----


    *& Form handle_double_click

    &----


    • text

    ----


    • -->P_E_ROW text

    • -->P_E_COLUMN text

    • -->P_ES_ROW_NUMBER text

    ----


    FORM handle_double_click USING e_row TYPE lvc_s_row

    e_column TYPE lvc_s_col

    e_row_number TYPE lvc_s_roid.

    DATA : output TYPE zalv.

    READ TABLE out_tab2 INTO output INDEX e_row-index.

    IF sy-subrc = 0 AND e_column-fieldname eq 'TPLNR'.

    SET PARAMETER ID 'KAS' FIELD OUTPUT-TPLNR.

    CALL TRANSACTION 'ZFLOCSMART' AND SKIP FIRST SCREEN .

    • delete from memory id 'kas'.

    ENDIF.

    ENDFORM. " handle_double_click

    &----


    *& Form top_of_page

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form top_of_page .

    write : / 'THESE ARE THE FUNCTIONAL LOCATION DETAILS'.

    endform. " top_of_page

    --


    END OF PROGRAM ZFLOC--

    .reward if this is usefull

Add a comment
10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.