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

field selection in simple list

Former Member
0 Likes
788

Hello,

I have a simple list report with a lot of figures.When I click on a figure I want to know where I made the click on tha screen, in order to show some details.

Can u help me?

Thank you!

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
750

Here is a short sample program which will help you understand how to do it. This is just one way of doing it.




report zrich_0002 no standard page heading.

data: ivbak type table of vbak with header line.

data : cursor_field(30),
       cursor_line type i.

select-options: s_vbeln for ivbak-vbeln.

start-of-selection.

  select * into corresponding fields of table ivbak
      from vbak
          where vbeln in s_vbeln.

  loop at ivbak.
    format hotspot on.
    write:/ ivbak-vbeln.
    format hotspot off.
  endloop.

at line-selection.

  get cursor field cursor_field line cursor_line.

  read table ivbak index cursor_line.

  set parameter id 'AUN' field ivbak-vbeln.
  call transaction 'VA03' and skip first screen.

Regards,

Rich Heilman

Hello,

I have a simple list report with a lot of figures.When I click on a figure I want to know where I made the click on tha screen, in order to show some details.

Can u help me?

Thank you!

4 REPLIES 4
Read only

Former Member
0 Likes
750

do you mean that u want to know tha value of the field (and if possible, name of the field) that got selected.

Read only

rahulkavuri
Active Contributor
0 Likes
750

This refers to an example which works as per ur specification...Simple, copy paste the code and run this program....

Enable Hot Spot on for whatever fields u want... at line-selection event change the code in whatever way u want to make the field u clicked on the second screen or at the top-of-page or end-of-page

*&---------------------------------------------------------------------*
*& Report  ZFINAL_50657                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZFINAL_50657 MESSAGE-ID ZZ NO STANDARD PAGE HEADING.

*---------------------------------------------------------------------*
* Tables                                                              *
*---------------------------------------------------------------------*
TABLES: T001W.

*---------------------------------------------------------------------*
* Internal Tables                                                     *
*---------------------------------------------------------------------*
* work areas

DATA: BEGIN OF ITAB_50657_T001W OCCURS 0,
      WERKS LIKE T001W-WERKS,
      NAME1 LIKE T001W-NAME1,
      LAND1 LIKE T001W-LAND1,
      END OF ITAB_50657_T001W.

DATA: BEGIN OF ITAB_50657_MARC OCCURS 0,
      MATNR LIKE MARC-MATNR,
      WERKS LIKE MARC-WERKS,
      END OF ITAB_50657_MARC.

DATA: BEGIN OF ITAB_50657_MAKT OCCURS 0,
      MATNR LIKE MAKT-MATNR,
      MAKTX LIKE MAKT-MAKTX,
      END OF ITAB_50657_MAKT.

DATA: BEGIN OF ITAB_50657_MARA OCCURS 0,
      MATNR LIKE  MARA-MATNR,
      MTART LIKE  MARA-MTART,
      MEINS LIKE  MARA-MEINS,
      NTGEW LIKE  MARA-NTGEW,
      BRGEW LIKE  MARA-BRGEW,
      GEWEI LIKE  MARA-GEWEI,
      VOLUM LIKE  MARA-VOLUM,
      VOLEH LIKE  MARA-VOLEH,
      END OF ITAB_50657_MARA.

DATA: BEGIN OF ITAB_50657_SCRIPTS OCCURS 0,
      MATNR LIKE MARC-MATNR,
      NAME1 LIKE T001W-NAME1,
      WERKS LIKE MARC-WERKS,
      PSTAT LIKE MARC-PSTAT,
      PRCTR LIKE MARC-PRCTR,
      MINLS LIKE MARC-MINLS,
      MAXLS LIKE MARC-MAXLS,
      END OF ITAB_50657_SCRIPTS.

DATA: ITAB_50657_BDC_DATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
      ITAB_50657_BDC_MSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
*---------------------------------------------------------------------*
* Variables                                                           *
*---------------------------------------------------------------------*

DATA: V_50657_WERKS LIKE ITAB_50657_T001W-WERKS.
DATA: V_50657_VALUE LIKE ITAB_50657_T001W-WERKS.

DATA: V_NTGEW(15), V_BRGEW(15), V_VOLUM(15).

DATA: FLAG(1) VALUE 'X'.
DATA: OK_CODE TYPE SY-UCOMM.


**---------------------------------------------------------------------*
** Constants                                                           *
**---------------------------------------------------------------------*
*DATA:
*  YES(1)                     TYPE C           VALUE 'X',
*  NO(1)                      TYPE C           VALUE ' '.

***********************************************************************
* Start of Program                                                    *
***********************************************************************

*---------------------------------------------------------------------*
*       INITIALIZATION.                                               *
*---------------------------------------------------------------------*
INITIALIZATION.
*--------------*

*---------------------------------------------------------------------*
*       SELECTION-SCREEN                                              *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.
*---------------------*

*---------------------------------------------------------------------*
*       START-OF-SELECTION                                            *
*---------------------------------------------------------------------*
START-OF-SELECTION.
*------------------*

  PERFORM PLANT_DETAILS.


*---------------------------------------------------------------------*
*       END-OF-SELECTION                                              *
*---------------------------------------------------------------------*
END-OF-SELECTION.
*----------------*

<b>  LOOP AT ITAB_50657_T001W.

    WRITE:/20 ITAB_50657_T001W-WERKS HOTSPOT ON,
           35 ITAB_50657_T001W-NAME1,
           70 ITAB_50657_T001W-LAND1.

    HIDE ITAB_50657_T001W-WERKS.


  ENDLOOP.</b>

*---------------------------------------------------------------------*
*       TOP-OF-PAGE                                                   *
*---------------------------------------------------------------------*
TOP-OF-PAGE.
*-----------*
* write report header

  WRITE:/20 'IGA'.
  WRITE:/ SY-ULINE.
  WRITE:/20 'PLANT NUMBER',35 'PLANT NAME',70 'COUNTRY'.
  WRITE:/ SY-ULINE.

* write out the column headings.


*---------------------------------------------------------------------*
*       TOP-OF-PAGE-DURING-LINE-SELECTION                             *
*---------------------------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.

  WRITE:/20 'HEADER DETAILS'.
  WRITE:/ SY-ULINE.
  WRITE:/20 'MATERIAL NUMBER', 45 'MATERIAL DESCRIPTION'.
  WRITE:/ SY-ULINE.


*---------------------------------------------------------------------*
*       END-OF-PAGE                                                   *
*---------------------------------------------------------------------*
END-OF-PAGE.
  WRITE:/ SY-PAGNO.
*-----------*
* write report footers

*---------------------------------------------------------------------*
*       AT LINE-SELECTION                                             *
*---------------------------------------------------------------------*
<b>AT LINE-SELECTION.

  IF SY-LSIND = 1.

    PERFORM GET_MAT_DETAILS.
    PERFORM DISPLAY_DETAILS.


  ENDIF.

  IF SY-LSIND = 2.

    PERFORM GET_DETAILS_MARA.
    CALL SCREEN 100.

  ENDIF.</b>

*&--------------------------------------------------------------------*
*&      Form  PLANT_DETAILS
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM PLANT_DETAILS.

  SELECT WERKS
         NAME1
         LAND1
         FROM T001W INTO TABLE ITAB_50657_T001W.

ENDFORM.                    "PLANT_DETAILS

*&--------------------------------------------------------------------*
*&      Form  GET_MAT_DETAILS
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM GET_MAT_DETAILS.

  SELECT MATNR
         WERKS
         FROM MARC INTO TABLE ITAB_50657_MARC
         WHERE WERKS = ITAB_50657_T001W-WERKS.

  SORT ITAB_50657_MARC BY MATNR.

  SELECT MATNR
         MAKTX
         FROM MAKT INTO TABLE ITAB_50657_MAKT
         FOR ALL ENTRIES IN ITAB_50657_MARC
         WHERE MATNR = ITAB_50657_MARC-MATNR.

  APPEND ITAB_50657_MAKT.

  SORT ITAB_50657_MAKT BY MATNR.

  IF SY-SUBRC <> 0.
    MESSAGE I000 WITH 'NO MATERIAL DETAILS FOUND FOR THIS PLANT'.
  ENDIF.


ENDFORM.                    "GET_MAT_DETAILS

*&--------------------------------------------------------------------*
*&      Form  DISPLAY_DETAILS
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM DISPLAY_DETAILS.

  LOOP AT ITAB_50657_MAKT.

    WRITE:/20 ITAB_50657_MAKT-MATNR,45 ITAB_50657_MAKT-MAKTX.
    HIDE ITAB_50657_MAKT-MATNR.

  ENDLOOP.

ENDFORM.                    "DISPLAY_DETAILS

*&--------------------------------------------------------------------*
*&      Form  GET_DETAILS_MARA
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM GET_DETAILS_MARA.


ENDFORM.                    "GET_DETAILS_MARA
*&---------------------------------------------------------------------*
*&      Module  FETCH_VALUES  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE FETCH_VALUES OUTPUT.

  SELECT SINGLE MATNR
         MTART
         MEINS
         NTGEW
         BRGEW
         GEWEI
         VOLUM
         VOLEH
         FROM MARA INTO ITAB_50657_MARA
         WHERE MATNR = ITAB_50657_MAKT-MATNR.

  IF FLAG = 'X'.
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'G1'.
        SCREEN-INPUT = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

ENDMODULE.                 " FETCH_VALUES  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.

     PERFORM SCRIPTS_PRINT.

    CASE OK_CODE.

    WHEN 'PRINT'.

      CALL FUNCTION 'OPEN_FORM'
       EXPORTING
*   APPLICATION                       = 'TX'
*   ARCHIVE_INDEX                     =
*   ARCHIVE_PARAMS                    =
*   DEVICE                            = 'PRINTER'
         DIALOG                            = 'X'
         FORM                              = 'ZFINAL_50657'
*   LANGUAGE                          = SY-LANGU
*   OPTIONS                           =
*   MAIL_SENDER                       =
*   MAIL_RECIPIENT                    =
*   MAIL_APPL_OBJECT                  =
*   RAW_DATA_INTERFACE                = '*'
*   SPONUMIV                          =
* IMPORTING
*   LANGUAGE                          =
*   NEW_ARCHIVE_PARAMS                =
*   RESULT                            =
* EXCEPTIONS
*   CANCELED                          = 1
*   DEVICE                            = 2
*   FORM                              = 3
*   OPTIONS                           = 4
*   UNCLOSED                          = 5
*   MAIL_OPTIONS                      = 6
*   ARCHIVE_ERROR                     = 7
*   INVALID_FAX_NUMBER                = 8
*   MORE_PARAMS_NEEDED_IN_BATCH       = 9
*   SPOOL_ERROR                       = 10
*   CODEPAGE                          = 11
*   OTHERS                            = 12
                .
      IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

LOOP AT ITAB_50657_SCRIPTS.

        CALL FUNCTION 'WRITE_FORM'
         EXPORTING
*   ELEMENT                        = ' '
           FUNCTION                       = 'SET'
           TYPE                           = 'BODY'
           WINDOW                         = 'MAIN'
* IMPORTING
*   PENDING_LINES                  =
     EXCEPTIONS
       ELEMENT                        = 1
       FUNCTION                       = 2
       TYPE                           = 3
       UNOPENED                       = 4
       UNSTARTED                      = 5
       WINDOW                         = 6
       BAD_PAGEFORMAT_FOR_PRINT       = 7
       SPOOL_ERROR                    = 8
       CODEPAGE                       = 9
       OTHERS                         = 10
                  .
        IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

      ENDLOOP.


      CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
*   RESULT                         =
*   RDI_RESULT                     =
* TABLES
*   OTFDATA                        =
* EXCEPTIONS
*   UNOPENED                       = 1
*   BAD_PAGEFORMAT_FOR_PRINT       = 2
*   SEND_ERROR                     = 3
*   SPOOL_ERROR                    = 4
*   CODEPAGE                       = 5
*   OTHERS                         = 6
                .
      IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

    WHEN 'CHANGE'.

      PERFORM UPDATE.

  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT



*&--------------------------------------------------------------------*
*&      Form  SCRIPTS_PRINT
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM SCRIPTS_PRINT.

  DATA: BEGIN OF ITAB_MAKT OCCURS 0,
        WERKS LIKE T001W-WERKS,
        NAME1 LIKE T001W-NAME1,
        END OF ITAB_MAKT.

  SELECT MATNR
         WERKS
         PSTAT
         PRCTR
         MINLS
         MAXLS
         FROM MARC INTO CORRESPONDING FIELDS OF TABLE ITAB_50657_SCRIPTS
         WHERE MATNR = ITAB_50657_MARA-MATNR.

  SORT ITAB_50657_SCRIPTS BY WERKS.

  SELECT WERKS
         NAME1
         FROM T001W INTO TABLE ITAB_MAKT
         FOR ALL ENTRIES IN ITAB_50657_SCRIPTS
         WHERE WERKS = ITAB_50657_SCRIPTS-WERKS.

  APPEND ITAB_MAKT.

  SORT ITAB_MAKT BY WERKS.

  LOOP AT ITAB_MAKT.

    READ TABLE ITAB_50657_SCRIPTS WITH KEY WERKS = ITAB_MAKT.

    IF SY-SUBRC = 0.
      ITAB_50657_SCRIPTS-NAME1 = ITAB_MAKT-NAME1.
    ENDIF.

    APPEND ITAB_50657_SCRIPTS.

  ENDLOOP.

  SORT ITAB_50657_SCRIPTS BY NAME1.


ENDFORM.                    "SCRIPTS_PRINT



*&---------------------------------------------------------------------*
*&      Form  update
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

*----------------------------------------------------------------------*
FORM UPDATE .


  IF SY-DATAR IS INITIAL.
    MESSAGE I000 WITH 'Material is not changed'.
  ELSE.

    V_NTGEW = ITAB_50657_MARA-NTGEW.
    V_BRGEW = ITAB_50657_MARA-BRGEW.
    V_VOLUM = ITAB_50657_MARA-VOLUM.

    PERFORM POPULATE_BDC.

  ENDIF.

ENDFORM.                    " update

*&--------------------------------------------------------------------*
*&      Form  POPULATE_BDC
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM POPULATE_BDC .

  PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                'RMMG1-MATNR'.

  PERFORM BDC_FIELD       USING 'RMMG1-MATNR'
                                 ITAB_50657_MARA-MATNR.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                'ENTR'.

  PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0070'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                'MSICHTAUSW-DYTXT(01)'.
  PERFORM BDC_FIELD       USING 'MSICHTAUSW-KZSEL(01)'
                                 'X'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                '=ENTR'.
  PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4004'.

  PERFORM BDC_FIELD       USING 'MARA-MEINS'
                               ITAB_50657_MARA-MEINS.
  PERFORM BDC_FIELD       USING 'MARA-NTGEW'
                                 V_NTGEW.
  PERFORM BDC_FIELD       USING 'MARA-BRGEW'
                                 V_BRGEW.
  PERFORM BDC_FIELD       USING 'MARA-GEWEI'
                               ITAB_50657_MARA-GEWEI.
  PERFORM BDC_FIELD       USING 'MARA-VOLUM'
                                 V_VOLUM.
  PERFORM BDC_FIELD       USING 'MARA-VOLEH'
                               ITAB_50657_MARA-VOLEH.

  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                'BU'.

  CALL TRANSACTION 'MM02' USING ITAB_50657_BDC_DATA MODE 'N' UPDATE 'A'
  MESSAGES INTO ITAB_50657_BDC_MSG.

  REFRESH ITAB_50657_BDC_DATA.

ENDFORM.                    " populate_bdc_table

*&---------------------------------------------------------------------*
*&      Form  bdc_dynpro
*&---------------------------------------------------------------------*

FORM BDC_DYNPRO  USING    PROGRAM
                          SCREEN.

  CLEAR ITAB_50657_BDC_DATA.
  ITAB_50657_BDC_DATA-PROGRAM = PROGRAM.
  ITAB_50657_BDC_DATA-DYNPRO = SCREEN.
  ITAB_50657_BDC_DATA-DYNBEGIN = 'X'.

  APPEND ITAB_50657_BDC_DATA.


ENDFORM.                    " bdc_dynpro

*&---------------------------------------------------------------------*
*&      Form  bdc_field
*&---------------------------------------------------------------------*

FORM BDC_FIELD  USING    FNAM
                         FVAL.
  CLEAR ITAB_50657_BDC_DATA.
  ITAB_50657_BDC_DATA-FNAM = FNAM.
  ITAB_50657_BDC_DATA-FVAL = FVAL.

  APPEND ITAB_50657_BDC_DATA.

ENDFORM.                    " bdc_field

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
751

Here is a short sample program which will help you understand how to do it. This is just one way of doing it.




report zrich_0002 no standard page heading.

data: ivbak type table of vbak with header line.

data : cursor_field(30),
       cursor_line type i.

select-options: s_vbeln for ivbak-vbeln.

start-of-selection.

  select * into corresponding fields of table ivbak
      from vbak
          where vbeln in s_vbeln.

  loop at ivbak.
    format hotspot on.
    write:/ ivbak-vbeln.
    format hotspot off.
  endloop.

at line-selection.

  get cursor field cursor_field line cursor_line.

  read table ivbak index cursor_line.

  set parameter id 'AUN' field ivbak-vbeln.
  call transaction 'VA03' and skip first screen.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
750

hi

chk this out

<b>

GET CURSOR</b>

Basic form 2

GET CURSOR ...

Variants:

1. GET CURSOR FIELD f.

2. GET CURSOR LINE line.

Variant 1

GET CURSOR FIELD f.

Extras:

1. ... OFFSET off

2. ... LINE line

3. ... VALUE g

4. ... LENGTH len

Effect

Transfers the name of the field at the cursor position to the field f.

The Return Code is set as follows:

SY-SUBRC = 0:

Cursor was positioned on a field.

SY-SUBRC = 4:

Cursor was not positioned on a field.

Note

Unlike screen processing, list processing allows you to output literals, field symbols, parameters and local variables of subroutines. Literals, local variables, VALUE parameters of subroutines, and object attributes are treated like fields without names (field name SPACE, return value 0).

Otherwise, GET CURSOR FIELD returns only names of global fields, regardless of whether they are addressed directly (i.e. by " WRITE"), by field symbols or by reference parameters.

With field symbols, this depends on whether the variable assigned is local or global. An assignment made using LOOP ASSIGNING does not return a field name for the field symbol since a table work area is always local.

Example

<b>DATA: CURSORFIELD(20),

GLOB_FIELD(20) VALUE 'global field',

REF_PARAMETER(30) VALUE 'parameter by reference',

VAL_PARAMETER(30) VALUE 'parameter by value',

FIELD_SYMBOL(20) VALUE 'field symbol'.

FIELD-SYMBOLS: <F> TYPE ANY.

PERFORM WRITE_LIST USING REF_PARAMETER VAL_PARAMETER.

ASSIGN GLOB_FIELD TO <F>.

AT LINE-SELECTION.

GET CURSOR FIELD CURSORFIELD.

WRITE: / CURSORFIELD, SY-SUBRC.

FORM WRITE_LIST USING RP VALUE(VP).

DATA: LOK_FIELD(20) VALUE 'local field'.

ASSIGN FIELD_SYMBOL TO <F>.

WRITE: / GLOB_FIELD, / LOC_FIELD,

/ RP, / VP,

/ 'literal', / FIELD_SYMBOL.

ENDFORM.</b>

When you double-click on the word " global field", CURSORFIELD contains the field name GLOB_FIELD, on "parameter by reference" the field name REF_PARAMETER, on " field symbol" the field name FIELD_SYMBOL, and on "local field", "parameter by value" and "literal" the value SPACE.

Addition 1

... OFFSET off

Effect

Copies the position of the cursor within the field to the field off (1st column = 0).

If the cursor is not somewhere within a field (SY-SUBRC = 4), the offset value is set to 0.

Addition 2

... LINE line

Effect

With step loops, lin contains the number of the loop line where the cursor stands. In list processing, this is the absolute line number (as stored in the system field SY-LILLI).

Addition 3

... VALUE g

Effect

g contains the value of the field where the cursor stands, always in output format (character display).

Addition 4

... LENGTH len

Effect

len contains the output length of the field where the cursor stands.

Note

If the data type of the field, on which the cursor is, is character-type, the LENGTH addition only works on lists. On screens, the system always returns the value 255.

Addition 5.. ... AREA a

Effect

If the cursor is positioned on the field of a table view control, the name of the control is placed in the field a.

Variant 2

GET CURSOR LINE line.

Extras:

1. ... OFFSET off

2. ... VALUE g

3. ... LENGTH len

Effect

As for variant 1 with addition LINE, except that there are differences with the return code and the effect of the additions.

The Return Code is set as follows:

SY-SUBRC = 0:

The cursor is on one of the list lines (list processing) or on a loop line (step loop).

SY-SUBRC = 4:

The cursor is not on one of the list or loop lines.

Addition 1

... OFFSET off

Effect

Applies to list processing only. The field off contains the position of the cursor relative to the beginning of the list line (1st column = 0). With horizontally shifted lists, the offset value can thus be greater than 0, even if the cursor is positioned on the extreme left of the window.

Addition 2

... VALUE g

Effect

List processing only. The field g contains the list line where the cursor is positioned.

Addition 3

... LENGTH len

Effect

List processing only. len contains the length of the line (LINE-SIZE).

<b>plz reward if useful</b>