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

Query in ALV

Former Member
0 Likes
1,689

Hi all,

Please clarify this query of Mine . I want to give standard F4 help for some of the fields in ALV output . Please tell me if this F4 help on some fields in the ALV output could be achieved without using OOPS concept.

Kindly reply as fast as possible.

Regards,

Vijay

Hi all,

Please clarify this query of Mine . I want to give standard F4 help for some of the fields in ALV output . Please tell me if this F4 help on some fields in the ALV output could be achieved without using OOPS concept.

Kindly reply as fast as possible.

Regards,

Vijay

9 REPLIES 9
Read only

Former Member
0 Likes
1,310

Hi,

use this fieldcat (slis_fieldcat_main1) through this pass reference field name and reference table name you will get f4 help for the required field.

regards,

suman

Read only

0 Likes
1,310

Hi Suman,

Thanks a lot for your reply . Can you kindly send me a sample code please .

Please reply as fast as possible.

Regards,

Vijay

Read only

0 Likes
1,310

Hi vijay,

I did one exampl for you please look at this.

REPORT Z_ALV_14797.

type-pools:slis.

  • final internal table declaration

data:begin of itab occurs 0,

vbeln(10) type c,

auart like vbak-auart,

audat like vbak-audat,

end of itab.

*internal table for fieldcat

data: it_fldcat type slis_t_fieldcat_alv,

wa_fldcat type slis_fieldcat_alv. "workarea for fieldcat

  • global variable for program name

data: g_repid type sy-repid.

*declaration for layout

data: ls_layout type slis_layout_alv.

*start of selection

select vbeln

auart

audat

up to 10 rows

from vbak

into table itab.

g_repid = sy-repid.

  • calling fieldcatalog function

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = g_repid

I_INTERNAL_TABNAME = 'ITAB'

I_INCLNAME = g_repid

CHANGING

ct_fieldcat = it_fldcat

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

perform fldcat.

*call list function

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = g_repid

IT_FIELDCAT = IT_FLDCAT

TABLES

t_outtab = itab

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 fldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fldcat .

loop at it_fldcat into wa_fldcat.

case wa_fldcat-fieldname.

when 'VBELN'.

wa_fldcat-ref_fieldname = 'VBELN'.

wa_fldcat-ref_tabname = 'VBAK'.

modify it_fldcat from wa_fldcat.

endcase.

endloop.

endform. " fldcat

<b>*reward points if useful</b>

regards

suman

Read only

0 Likes
1,310

Hi Suman,

Thank you very much for your reply . I have a small clarification in the code . Please clarify . SHould we give any search help for the table we are giving in the ref_tabname field . If we need to give please tell me how to give .

Thanks once again for your reply.

Please reply as fast as possible.

Regards,

Vijay

Read only

0 Likes
1,310

Hi bala,

You want the f4 help from table or you want t ouse search help.

regards

suman

Read only

0 Likes
1,310

Hi Suman,

Thanks very much for your reply . I want to give F4 help on one of the fields in ALV . Referring to your code you sent yesterday , I want to know whether anything else at the database table level(Like giving Search help for the field in the ALV output for which we need to have F4 help) needs to be done for getting F4 help on an ALV field .

KIndly reply as fast as possible please.

Thanks once again for your replies.

Regards,

Vijay

Read only

Former Member
0 Likes
1,310

Hi,

For giving default F4help which is available then you can make use of REF_FIELD , REF_TABLE this will enable F4 help.

I think this will solve ur problem...

Reward points if contents are useful..

Regards,

MANDEEP.

Read only

Former Member
0 Likes
1,310

<b>Please see this program it was having F4 help for all the fields...

only thing which you have to do is in the field catalog pass</b> fieldcatalog-

ref_tabname   = 'EKKO' .  "  < -  pass  the standart table  from which you 
" want the data 

*&---------------------------------------------------------------------*
REPORT  zdemo_alvgrid_f4HELP                 .

TABLES:     ekko.

type-pools: slis.                                 "ALV Declarations
*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
  statu TYPE ekpo-statu,
  aedat TYPE ekpo-aedat,
  matnr TYPE ekpo-matnr,
  menge TYPE ekpo-menge,
  meins TYPE ekpo-meins,
  netpr TYPE ekpo-netpr,
  peinh TYPE ekpo-peinh,
 END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
      wa_ekko TYPE t_ekko.

*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
      gd_tab_group type slis_t_sp_group_alv,
      gd_layout    type slis_layout_alv,
      gd_repid     like sy-repid.


************************************************************************
*Start-of-selection.
START-OF-SELECTION.

perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.


*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.

* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you  more control of the final product.

* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
*               I.e. Field type may be required in-order for
*                    the 'TOTAL' function to work.

  fieldcatalog-fieldname   = 'EBELN'.
  fieldcatalog-ref_tabname   = 'EKKO'.
  fieldcatalog-seltext_m   = 'Purchase Order'.
  fieldcatalog-col_pos     = 0.
  fieldcatalog-outputlen   = 10.
  fieldcatalog-emphasize   = 'X'.
  fieldcatalog-key         = 'X'.
*  fieldcatalog-do_sum      = 'X'.
*  fieldcatalog-no_zero     = 'X'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'EBELP'.
  fieldcatalog-ref_tabname   = 'EKKO'.

  fieldcatalog-seltext_m   = 'PO Item'.
  fieldcatalog-col_pos     = 1.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'STATU'.
  fieldcatalog-ref_tabname   = 'EKKO'.

  fieldcatalog-seltext_m   = 'Status'.
  fieldcatalog-col_pos     = 2.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'AEDAT'.
  fieldcatalog-ref_tabname   = 'EKKO'.

  fieldcatalog-seltext_m   = 'Item change date'.
  fieldcatalog-col_pos     = 3.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MATNR'.
  fieldcatalog-ref_tabname   = 'EKKO'.

  fieldcatalog-seltext_m   = 'Material Number'.
  fieldcatalog-col_pos     = 4.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MENGE'.
  fieldcatalog-ref_tabname   = 'EKKO'.
  fieldcatalog-seltext_m   = 'PO quantity'.
  fieldcatalog-col_pos     = 5.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MEINS'.
  fieldcatalog-ref_tabname   = 'EKKO'.
  fieldcatalog-seltext_m   = 'Order Unit'.
  fieldcatalog-col_pos     = 6.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'NETPR'.
  fieldcatalog-ref_tabname   = 'EKKO'.
  fieldcatalog-seltext_m   = 'Net Price'.
  fieldcatalog-col_pos     = 7.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-do_sum      = 'X'.        "Display column total
  fieldcatalog-datatype     = 'CURR'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'PEINH'.
  fieldcatalog-ref_tabname   = 'EKKO'.
  fieldcatalog-seltext_m   = 'Price Unit'.
  fieldcatalog-col_pos     = 8.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
endform.                    " BUILD_FIELDCATALOG


*&---------------------------------------------------------------------*
*&      Form  BUILD_LAYOUT
*&---------------------------------------------------------------------*
*       Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(201).
*  gd_layout-totals_only        = 'X'.
*  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
*                                         "click(press f2)
*  gd_layout-zebra             = 'X'.
*  gd_layout-group_change_edit = 'X'.
*  gd_layout-header_text       = 'helllllo'.
endform.                    " BUILD_LAYOUT


*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*       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
*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
*            i_callback_user_command = 'USER_COMMAND'
*            i_grid_title           = outtext
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
*            it_special_groups       = gd_tabgroup
*            IT_EVENTS                = GT_XEVENTS
            i_save                  = 'X'
*            is_variant              = z_template

       tables
            t_outtab                = it_ekko
       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.                    " DISPLAY_ALV_REPORT


*&---------------------------------------------------------------------*
*&      Form  DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*       Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh
 up to 10 rows
  from ekpo
  into table it_ekko.
endform.                    " DATA_RETRIEVAL

reward points if it is usefulll ..... enjoy the weekend

Girish