‎2009 Aug 19 11:01 AM
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
‎2009 Aug 20 5:57 AM
i am not getting field names in the grid...that's y i marked as unanswered....
‎2009 Aug 19 11:04 AM
Hi,
Refer the code for ALV display:-
Hope this helps you.
Regards,
Tarun Gambhir
‎2009 Aug 19 11:07 AM
FIELDCAT = it_fieldcat[].remove "." in this statement.
Regards,
Sumit.
‎2009 Aug 19 1:36 PM
thank you expert i done the program but still having a doubt....grid tab is coming empty...pls help me out in this
‎2009 Aug 19 11:09 AM
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
‎2009 Aug 19 11:10 AM
hi welcome,
read the forum rules first.
dont post more than 2500 characters in a thread.
paste the code within the code tag
‎2009 Aug 19 11:13 AM
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
‎2009 Aug 19 11:34 AM
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
‎2009 Aug 19 12:07 PM
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
‎2009 Aug 19 1:36 PM
thank you expert i done the program but still having a doubt....grid tab is coming empty...pls help me out in this
‎2009 Aug 20 5:57 AM
i am not getting field names in the grid...that's y i marked as unanswered....
‎2009 Aug 20 6:11 AM
Hi,
Use this field in the field catalog to populate the field names
it_fieldcat-seltext_l = 'Material'.
‎2009 Aug 20 6:18 AM
‎2009 Aug 20 6:32 AM
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
‎2009 Aug 20 7:06 AM