‎2007 Jun 21 8:45 PM
Hi ,
when i am executing the program,i am not any list out instead i am viewing blank list without no field values .
Here is my code:
type-pools:slis.
types:begin of s_sflight,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
price like sflight-price ,
seatsmax like sflight-seatsmax,
end of s_sflight.
data:it_sflight type standard table of s_sflight.
data:wa_sflight like it_sflight.
data:t_fieldcat type slis_t_fieldcat_alv ,"WITH HEADER LINE,
v_repid like sy-repid.
select carrid connid fldate price seatsmax
into table it_sflight from sflight.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'IT_SFLIGHT'
I_STRUCTURE_NAME = 'S_SFLIGHT'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = v_repid
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
CHANGING
CT_FIELDCAT = t_fieldcat
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.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'S_SFLIGHT'
IS_LAYOUT =
IT_FIELDCAT = t_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_SFLIGHT
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.
‎2007 Jun 21 9:51 PM
Hi Rajasekhar,
Check this code.
*&---------------------------------------------------------------------*
*& Report ZTEST100
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST100.
type-pools:slis.
types:begin of s_sflight,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
price like sflight-price ,
seatsmax like sflight-seatsmax,
end of s_sflight.
data:it_sflight type standard table of s_sflight.
data:wa_sflight like it_sflight.
data:t_fieldcat type slis_t_fieldcat_alv ,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
v_repid like sy-repid.
select carrid connid fldate price seatsmax
into table it_sflight from sflight.
WA_fieldcat-fieldname = 'CARRID'.
wa_fieldcat-reptext_ddic = 'Airline Code'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'CONNID'.
wa_fieldcat-reptext_ddic = 'Fl. Conn. NO.'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'FLDATE'.
wa_fieldcat-reptext_ddic = 'Flight date'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'PRICE'.
wa_fieldcat-reptext_ddic = 'Airfare'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'SEATSMAX'.
wa_fieldcat-reptext_ddic = 'Maximum capacity in economy class'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'S_SFLIGHT'
* IS_LAYOUT =
IT_FIELDCAT = t_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A'
* 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
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_SFLIGHT
* 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.Regards
Aneesh.
‎2007 Jun 21 9:33 PM
Field catalog is empty now. you can populate like
type-pools:slis.
types:begin of s_sflight,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
price like sflight-price ,
seatsmax like sflight-seatsmax,
end of s_sflight.
data:it_sflight type standard table of s_sflight.
data:wa_sflight like it_sflight.
data:t_fieldcat type slis_t_fieldcat_alv ,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
v_repid like sy-repid.
select carrid connid fldate price seatsmax
into table it_sflight from sflight.
WA_fieldcat-fieldname = 'CARRID'.
wa_fieldcat-reptext_ddic = 'Airline Code'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'CONNID'.
wa_fieldcat-reptext_ddic = 'Fl. Conn. NO.'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'FLDATE'.
wa_fieldcat-reptext_ddic = 'Flight date'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'PRICE'.
wa_fieldcat-reptext_ddic = 'Airfare'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'SEATSMAX'.
wa_fieldcat-reptext_ddic = 'Maximum capacity in economy class'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'S_SFLIGHT'
IS_LAYOUT =
IT_FIELDCAT = t_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_SFLIGHT
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.
‎2007 Jun 21 9:48 PM
You can still use the FM to populate the field catalog. Just define the internal table like this:
data: begin of s_sflight2,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
price LIKE sflight-price ,
seatsmax LIKE sflight-seatsmax,
end of s_sflight2.And move the internal table name to a varaible like this:
data: p_tabname TYPE slis_fieldcat_alv-tabname
move 'S_SFLIGHT2' to p_tabname.Then call the field catalog FM:
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-cprog
i_internal_tabname = p_tabname
*i_structure_name = p_tabname
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-cprog
i_bypassing_buffer = 'X'
i_buffer_active = ' '
CHANGING
ct_fieldcat = t_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.This should give you the output.
<b>Points are always welcome!!</b>
Minami
‎2007 Jun 21 9:51 PM
Hi Rajasekhar,
Check this code.
*&---------------------------------------------------------------------*
*& Report ZTEST100
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST100.
type-pools:slis.
types:begin of s_sflight,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
price like sflight-price ,
seatsmax like sflight-seatsmax,
end of s_sflight.
data:it_sflight type standard table of s_sflight.
data:wa_sflight like it_sflight.
data:t_fieldcat type slis_t_fieldcat_alv ,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
v_repid like sy-repid.
select carrid connid fldate price seatsmax
into table it_sflight from sflight.
WA_fieldcat-fieldname = 'CARRID'.
wa_fieldcat-reptext_ddic = 'Airline Code'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'CONNID'.
wa_fieldcat-reptext_ddic = 'Fl. Conn. NO.'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'FLDATE'.
wa_fieldcat-reptext_ddic = 'Flight date'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'PRICE'.
wa_fieldcat-reptext_ddic = 'Airfare'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
WA_fieldcat-fieldname = 'SEATSMAX'.
wa_fieldcat-reptext_ddic = 'Maximum capacity in economy class'.
APPEND WA_FIELDCAT TO T_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'S_SFLIGHT'
* IS_LAYOUT =
IT_FIELDCAT = t_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A'
* 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
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_SFLIGHT
* 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.Regards
Aneesh.
‎2007 Jun 21 10:41 PM
hi,
**decalre tables.
TABLES: sflight.
type-pools:slis.
****structure declaration
types:begin of s_sflight,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
price like sflight-price ,
seatsmax like sflight-seatsmax,
end of s_sflight.
**internal table declarations
data: wa_sflight like it_sflight.
data: it_sflight type standard table of s_sflight.
****field catalog declaration
data: t_fieldcat type slis_t_fieldcat_alv , "field catalog body,
v_repid like sy-repid.
start-of-selection.
select carrid connid fldate price seatsmax
into table it_sflight from sflight.
if sy-subrc = 0. " or IF it_sflight IS NOT INITIAL.
function module for providing field catalog
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'it_sflight'
I_STRUCTURE_NAME = 's_sflight'
I_INCLNAME = v_repid
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
CHANGING
CT_FIELDCAT = t_fieldcat
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.
****function moddule for displayin data in alv report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_STRUCTURE_NAME = 's_sflight'
IT_FIELDCAT = t_fieldcat
I_SAVE = 'A'
TABLES
T_OUTTAB = it_sflight.
1) in your program you declared internal table, structure and field catalog in small letetrs but you are passing as capital letters. you must take care while passing structure to the parameter of <b>reuse_alv_fieldcatalog_merge</b> function module because it can create field catalog for the entaire report based on structure only.
2) better to declare tables which are used for data reading.
3) Before dispalying data once check IF it_sflight IS NOT INITIAL and call function modules with in this and end with ENDIF.
4) better to design selection-screen for user input, based on that you can read data.
regards,
Ashokreddy