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

help!!! a simple ALV program.

Former Member
0 Likes
787

encounter a runtime error.What is the problem.

REPORT YTEST27.

type-pools:slis.

data wa_alv_field type slis_fieldcat_alv.

data wa_alv_fieldcat type slis_t_fieldcat_alv.

data wa_spfli like table of spfli with header line.

select * into table wa_spfli from spfli.

wa_alv_field-col_pos = 1.

wa_alv_field-fieldname = 'CARRDI'.

wa_alv_field-seltext_m = '航线承运人'.

append wa_alv_field to wa_alv_fieldcat.

wa_alv_field-col_pos = 2.

wa_alv_field-fieldname = 'CONNID'.

wa_alv_field-seltext_m = '航班连接'.

append wa_alv_field to wa_alv_fieldcat.

wa_alv_field-col_pos = 3.

wa_alv_field-fieldname = 'CITYFROM'.

wa_alv_field-seltext_m = '起飞城市'.

append wa_alv_field to wa_alv_fieldcat.

wa_alv_field-col_pos = 4.

wa_alv_field-fieldname = 'CITYTO'.

wa_alv_field-seltext_m = '起飞城市'.

append wa_alv_field to wa_alv_fieldcat.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

IT_FIELDCAT = wa_alv_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

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = wa_spfli

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

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
764

Hello Alex

There is hardly any good reason why you should create the fieldcatalog manually. One obvious mistake is the misspelled fieldname for CARRID (CARRDI).

Instead, use the fm REUSE_ALV_FIELDCATALOG_MERGE to create the fieldcatalog automatically.

Final remark: If you do not have good reason to still use this stone-age ALV programming (SLIS based) then move at least to fm's REUSE_ALV_GRID_DISPLAY_LVC and LVC_FIELDCATALOG_MERGE.

Regards

Uwe

7 REPLIES 7
Read only

Former Member
0 Likes
764

what is the runtime error??

Read only

0 Likes
764

Runtime Errors GETWA_NOT_ASSIGNED

Read only

Former Member
0 Likes
764

>

> encounter a runtime error.What is the problem.

>

> REPORT YTEST27.

>

> type-pools:slis.

>

> data wa_alv_field type slis_fieldcat_alv.

>

> data wa_alv_fieldcat type slis_t_fieldcat_alv.

>

> data wa_spfli like table of spfli with header line.

>

> select * into table wa_spfli from spfli.

>

> wa_alv_field-col_pos = 1.

> wa_alv_field-fieldname = 'CARRDI'.

> wa_alv_field-seltext_m = '航线承运人'.

> append wa_alv_field to wa_alv_fieldcat.

>

> wa_alv_field-col_pos = 2.

> wa_alv_field-fieldname = 'CONNID'.

> wa_alv_field-seltext_m = '航班连接'.

> append wa_alv_field to wa_alv_fieldcat.

>

> wa_alv_field-col_pos = 3.

> wa_alv_field-fieldname = 'CITYFROM'.

> wa_alv_field-seltext_m = '起飞城市'.

> append wa_alv_field to wa_alv_fieldcat.

>

> wa_alv_field-col_pos = 4.

> wa_alv_field-fieldname = 'CITYTO'.

> wa_alv_field-seltext_m = '起飞城市'.

> append wa_alv_field to wa_alv_fieldcat.

>

> CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

> EXPORTING

> * I_INTERFACE_CHECK = ' '

> * I_BYPASSING_BUFFER =

> * I_BUFFER_ACTIVE = ' '

> * I_CALLBACK_PROGRAM = ' '

> * I_CALLBACK_PF_STATUS_SET = ' '

> * I_CALLBACK_USER_COMMAND = ' '

> * I_STRUCTURE_NAME =

> * IS_LAYOUT =

> IT_FIELDCAT = wa_alv_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

> * IR_SALV_LIST_ADAPTER =

> * IT_EXCEPT_QINFO =

> * I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

> * IMPORTING

> * E_EXIT_CAUSED_BY_CALLER =

> * ES_EXIT_CAUSED_BY_USER =

> TABLES

> T_OUTTAB = wa_spfli

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

Hi

*"Table declarations...................................................

TABLES:

sflight.

*"Type pools declarations..............................................

TYPE-POOLS:

slis.

*"Data declarations...................................................

DATA:

BEGIN OF fs_sflight,

carrid LIKE sflight-carrid,

connid LIKE sflight-connid,

fldate LIKE sflight-fldate,

seatsmax LIKE sflight-seatsmax,

seatsocc LIKE sflight-seatsocc,

END OF fs_sflight.

*"Data declarations...................................................

DATA:

t_fieldcat TYPE slis_t_fieldcat_alv,

l_fieldcat LIKE LINE OF t_fieldcat.

"----


  • Internal table to hold flight schedule information *

"----


DATA:

t_sflight LIKE

STANDARD TABLE OF fs_sflight.

PERFORM t_fieldcat.

PERFORM get_sflight_details.

&----


*& Form get_sflight_details

----


  • This subroutine retrieves necessary data from sflight and to display

  • flight details *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM get_sflight_details.

SELECT carrid

connid

fldate

seatsmax

seatsocc

FROM sflight

INTO TABLE t_sflight.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = t_fieldcat

TABLES

t_outtab = t_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.

endform. " get-sflight_details.

&----


*& Form t_fieldcat

----


  • This subroutine fill necessary data into t_fieldcat *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM t_fieldcat .

CLEAR t_fieldcat.

PERFORM fill_field USING 'CARRID' 'carrid'.

PERFORM fill_field USING 'CONNID' 'connid'.

PERFORM fill_field USING 'FLDATE' 'fldate'.

PERFORM fill_field USING 'SEATSMAX' 'seatsmax'.

PERFORM fill_field USING 'SEATSOCC' 'seatsocc'.

ENDFORM. " t_fieldcat

&----


*& Form fill_field

----


  • This subroutine fill necessary data into l_fieldcat *

----


  • -->P_fieldname

  • -->P_seltext

----


FORM fill_field USING p_fieldname

p_seltext.

l_fieldcat-fieldname = p_fieldname.

l_fieldcat-tabname = 'T_SPFLI'.

l_fieldcat-seltext_m = p_seltext.

APPEND l_fieldcat TO t_fieldcat.

CLEAR l_fieldcat.

ENDFORM. " fill_field

Regards,

Sravanthi

Read only

former_member745780
Active Participant
0 Likes
764

hello

pass internal table to FM

wa_spfli[]

and also check your fieldcatalog must be same as structure of the internal table wa_spfli .

define internal table like this as per yuor fieldcatalog



data: begin of wa_spfli occurs 0,
           carrid like spfli-carrid,
           connid like spfli-connid,
           cityfrom like spfli-cityfrom,
           cityto like spfli-cityto,
        end of wa_spfli.

Thanks

Anirudh

Edited by: ANIRUDH SAINI on Aug 14, 2008 6:25 AM

Read only

Former Member
0 Likes
764

i feel there are two changes one

wa_alv_field-col_pos = 4.
wa_alv_field-fieldname = 'CITYTO'.
wa_alv_field-tabname = 'WA_SPFLI'   "<-----Inetrnal Tablename
wa_alv_field-seltext_m = 'u8D77u98DEu57CEu5E02'.
append wa_alv_field to wa_alv_fieldcat.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid "<---------Use this
IT_FIELDCAT = wa_alv_fieldcat 
TABLES
T_OUTTAB = wa_spfli
EXCEPTIONS 
PROGRAM_ERROR = 1 
OTHERS = 2 
.
IF SY-SUBRC ne  0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
ENDIF.

Read only

uwe_schieferstein
Active Contributor
0 Likes
765

Hello Alex

There is hardly any good reason why you should create the fieldcatalog manually. One obvious mistake is the misspelled fieldname for CARRID (CARRDI).

Instead, use the fm REUSE_ALV_FIELDCATALOG_MERGE to create the fieldcatalog automatically.

Final remark: If you do not have good reason to still use this stone-age ALV programming (SLIS based) then move at least to fm's REUSE_ALV_GRID_DISPLAY_LVC and LVC_FIELDCATALOG_MERGE.

Regards

Uwe

Read only

0 Likes
764

hi

thanks for your help.