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

doubt on alv program

Former Member
0 Likes
1,679

hi experts

i am trying to do a alv program...the following is the coding of my program..i am getting an error "." is expected after t_outtab..i am new to abap...can anyone help to fix this problem....

REPORT ZALV .

tables:mara.

select-options : s_matnr for mara-matnr.

data:begin of it_mara occurs 0,

matnr like mara-matnr,

mtart like mara-mtart,

brgew like mara-brgew,

ntgew like mara-ntgew,

end of it_mara.

type-pools:slis.

data:it_fieldcat type slis_t_fieldcat_alv with header line.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = 'sy-repid '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_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 =

IT_FIELDCAT = it_fieldcat[].

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_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

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = it_mara

  • 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.

start-of-selection.

select matnr

mtart

brgew

ntgew from mara into table it_mara where matnr in s_matnr.

it_fieldcat-col_pos = 1.

it_fieldcat-fieldname = 'MATNR'.

it_fieldcat-tabname = 'MATERIAL'.

it_fieldcat-outputlen = 18.

it_fieldcat-tabname = 'IT_MARA'.

append it_fieldcat.

it_fieldcat-col_pos = 1.

it_fieldcat-fieldname = 'MTART'.

it_fieldcat-tabname = 'TYPE'.

it_fieldcat-outputlen = 4 .

it_fieldcat-tabname = 'IT_MARA'.

append it_fieldcat.

it_fieldcat-col_pos = 1.

it_fieldcat-fieldname = 'BRGEW'.

it_fieldcat-tabname = 'GROSS WEIGHT'.

it_fieldcat-outputlen = 19.

it_fieldcat-tabname = 'IT_MARA'.

append it_fieldcat.

it_fieldcat-col_pos = 1.

it_fieldcat-fieldname = 'NTGEW'.

it_fieldcat-tabname = 'NET WEIGHT'.

it_fieldcat-outputlen = 19.

it_fieldcat-tabname = 'IT_MARA'.

append it_fieldcat.

end-of-selection.

Edited by: karthicksap on Aug 19, 2009 12:01 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,471

i am not getting field names in the grid...that's y i marked as unanswered....

14 REPLIES 14
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,471

Hi,

Refer the code for ALV display:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin...

Hope this helps you.

Regards,

Tarun Gambhir

Read only

Former Member
0 Likes
1,471
FIELDCAT = it_fieldcat[].

remove "." in this statement.

Regards,

Sumit.

Read only

0 Likes
1,471

thank you expert i done the program but still having a doubt....grid tab is coming empty...pls help me out in this

Read only

Former Member
0 Likes
1,471

Hi,

Please remove the '.' after



IT_FIELDCAT = it_fieldcat[]

Your FM is not over as yet.

Before passing your fieldcatalog to the FM, populate your field catalog with data. Your code seems to be populating the field catalog after calling the FM. Please check on that

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,471

hi welcome,

read the forum rules first.

dont post more than 2500 characters in a thread.

paste the code within the code tag

Read only

Former Member
0 Likes
1,471

Hi,

Try this code,


REPORT ZALV .
tables:mara. 
select-options : s_matnr for mara-matnr. 
data:begin of it_mara occurs 0,
matnr like mara-matnr, 
mtart like mara-mtart, 
brgew like mara-brgew,
ntgew like mara-ntgew, 
end of it_mara. 
type-pools:slis. 
data:it_fieldcat type slis_t_fieldcat_alv with header line. 

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' 
EXPORTING * 
I_INTERFACE_CHECK = ' ' 
* I_BYPASSING_BUFFER = ' '
 * I_BUFFER_ACTIVE = ' ' 
* I_CALLBACK_PROGRAM = 'sy-repid ' 
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' ' 
* I_CALLBACK_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 = 
IT_FIELDCAT = it_fieldcat[]           "---------------> Remove the period here
* IT_EXCLUDING = 
* IT_SPECIAL_GROUPS = 
* IT_SORT = 
* IT_FILTER = 
* IS_SEL_HIDE = 
* I_DEFAULT = 'X' 
* I_SAVE = ' ' 
* IS_VARIANT = 
* IT_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 
* IT_ALV_GRAPHICS = 
* IT_HYPERLINK = 
* IT_ADD_FIELDCAT = 
* IT_EXCEPT_QINFO = 
* I_HTML_HEIGHT_TOP = 
* I_HTML_HEIGHT_END = 
* IMPORTING 
* E_EXIT_CAUSED_BY_CALLER = 
* ES_EXIT_CAUSED_BY_USER = 
TABLES T_OUTTAB = it_mara 
* 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.

 start-of-selection. 
select matnr mtart brgew ntgew from mara into table it_mara where matnr in s_matnr. 
it_fieldcat-col_pos = 1.
 it_fieldcat-fieldname = 'MATNR'. 
it_fieldcat-tabname = 'MATERIAL'.
 it_fieldcat-outputlen = 18. 
it_fieldcat-tabname = 'IT_MARA'.
 append it_fieldcat. 
it_fieldcat-col_pos = 1. 
it_fieldcat-fieldname = 'MTART'.
 it_fieldcat-tabname = 'TYPE'. 
it_fieldcat-outputlen = 4 . 
it_fieldcat-tabname = 'IT_MARA'. 
append it_fieldcat. 
it_fieldcat-col_pos = 1. 
it_fieldcat-fieldname = 'BRGEW'. 
it_fieldcat-tabname = 'GROSS WEIGHT'. 
it_fieldcat-outputlen = 19. 
it_fieldcat-tabname = 'IT_MARA'. 
append it_fieldcat. 
it_fieldcat-col_pos = 1. 
it_fieldcat-fieldname = 'NTGEW'. 
it_fieldcat-tabname = 'NET WEIGHT'. 
it_fieldcat-outputlen = 19. 
it_fieldcat-tabname = 'IT_MARA'. 
append it_fieldcat. end-of-selection

Read only

Former Member
0 Likes
1,471

Dear Karthicksap .

Looking at your code the only problem that i could find is

IT_FIELDCAT = it_fieldcat[].

Remove the . from this line and your code will work fine .

If any other confusion then you can go through

https://wiki.sdn.sap.com/wiki/display/HOME/objectorientedProgramminginALV .

Will help increase your knowledge.

Thanks and regards

Aditi Wason

Read only

Former Member
0 Likes
1,471

Hi,

You can try using the sample code below for calling that function module:




  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*    I_INTERFACE_CHECK                 = ' '
*    I_BYPASSING_BUFFER                = ' '
*    I_BUFFER_ACTIVE                   = ' '
      i_callback_program                = sy-repid
      i_callback_pf_status_set          = 'PF_STATUS'
      i_callback_user_command           = 'COMM'
      i_callback_top_of_page            = 'TOP'
*    I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*    I_CALLBACK_HTML_END_OF_LIST       = ' '
*    I_STRUCTURE_NAME                  =
*    I_BACKGROUND_ID                   = ' '
      i_grid_title                      = it_grid_title
*    I_GRID_SETTINGS                   =
      is_layout                         = it_layout
      it_fieldcat                       = it_field
*    it_excluding                      = itab_exclude
*    IT_SPECIAL_GROUPS                 =
      it_sort                           = itab_sort
*    IT_FILTER                         =
*    IS_SEL_HIDE                       =
*    I_DEFAULT                         = ''
    I_SAVE                            = 'A'
    IS_VARIANT                        = SVARIANT
      it_events                         = itab_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                          = it_tab
*  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.


Hope it helps

Regards

Mansi

Read only

0 Likes
1,471

thank you expert i done the program but still having a doubt....grid tab is coming empty...pls help me out in this

Read only

Former Member
0 Likes
1,472

i am not getting field names in the grid...that's y i marked as unanswered....

Read only

0 Likes
1,471

Hi,

Use this field in the field catalog to populate the field names



 it_fieldcat-seltext_l = 'Material'.

Read only

0 Likes
1,471

thank you very much......my problem solved

Read only

Former Member
0 Likes
1,471

Hi ,

there is no mistake in your code .

the problem is with the field cataloge values not goin to header .

Debug your program and you will know at which point the values are not transferring .

i suggest you to use a work area for field catalog .

wa_fieldcat-fieldname = 'NTGEW'.
wa_fieldcat-scrtext_m = 'NET WEIGHT'.
wa_fieldcat-outputlen = 19.
wa_fieldcat-tabname = 'IT_MARA'. 
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

Thanks and regards

Aditi Wason

Read only

0 Likes
1,471

hi

thanks for the solution...