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

wat is worng in this code?

Former Member
0 Likes
1,053

hi

TYPES :

BEGIN OF ts_ship ,

vbeln TYPE vbak-vbeln , "order number

ernam TYPE vbak-ernam ,

END OF ts_ship ,

tt_ship TYPE TABLE OF ts_ship.

DATA : gt_ship TYPE tt_ship.

DATA: gt_selected_rows TYPE lvc_t_row.

  • Custom container instance reference

DATA : g_control TYPE REF TO cl_gui_custom_container.

  • ALV Grid instance reference

DATA : g_alv TYPE REF TO cl_gui_alv_grid.

  • ALV list layout declaration

DATA : gs_layout TYPE lvc_s_layo.

  • Field catalog table

DATA : gt_fieldcat TYPE lvc_t_fcat.

START-OF-SELECTION.

DATA: ls_ship TYPE ts_ship.

SELECT vbeln ernam

FROM vbak

INTO TABLE gt_ship.

PERFORM fill_fieldcat CHANGING gt_fieldcat[].

  • &---------------------------------------------------------------------

*& Form fill_fieldcat

&----


  • text

----


  • <--P_GT_FIELDCAT[] text

----


FORM fill_fieldcat CHANGING ct_fieldcat TYPE lvc_t_fcat.

  • Local data

DATA : ls_fieldcat TYPE lvc_s_fcat.

REFRESH ct_fieldcat.

ls_fieldcat-fieldname = 'VBELN'.

ls_fieldcat-coltext = 'Order number'.

APPEND ls_fieldcat TO ct_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'ERNAM'.

ls_fieldcat-coltext = 'Name of Person'.

APPEND ls_fieldcat TO ct_fieldcat.

CLEAR ls_fieldcat.

ENDFORM. " fill_fieldcat

END-OF-SELECTION.

CALL SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'PF-0100'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module display OUTPUT

&----


  • text

----


MODULE display OUTPUT.

PERFORM set_windows_layout CHANGING gs_layout.

IF g_control IS INITIAL.

  • Create custom container object

CREATE OBJECT g_control

EXPORTING

container_name = 'ACTIVE_TEST'.

ENDIF.

  • ALV Grid instance reference

IF g_alv IS INITIAL.

CREATE OBJECT g_alv

EXPORTING

i_parent = g_control

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5

.

ENDIF.

      • Creating an instance for the event handler

    • CREATE OBJECT gv_event_handler .

  • Display grid via appropriate method of the grid object

CALL METHOD g_alv->set_table_for_first_display

EXPORTING

is_layout = gs_layout

CHANGING

it_outtab = gt_ship[]

it_fieldcatalog = gt_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

ENDMODULE. " display OUTPUT

&----


*& Module exit_program INPUT

&----


  • text

----


MODULE exit_program INPUT.

LEAVE TO SCREEN 0.

ENDMODULE. " exit_program INPUT

&----


*& Module user_command_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'BACK' .

LEAVE PROGRAM.

WHEN 'SELECT'.

  • get selected rows

REFRESH gt_selected_rows.

CALL METHOD g_alv->get_selected_rows

IMPORTING

et_index_rows = gt_selected_rows.

ENDCASE.

ENDMODULE. " user_command_0100 INPUT

&----


*& Form set_windows_layout

&----


  • text

----


  • <--P_GS_LAYOUT text

----


FORM set_windows_layout CHANGING cs_layout TYPE lvc_s_layo.

cs_layout-zebra = 'X'.

cs_layout-sel_mode = 'A'.

cs_layout-cwidth_opt = 'X'.

.

ENDFORM. " set_windows_layout

hi

TYPES :

BEGIN OF ts_ship ,

vbeln TYPE vbak-vbeln , "order number

ernam TYPE vbak-ernam ,

END OF ts_ship ,

tt_ship TYPE TABLE OF ts_ship.

DATA : gt_ship TYPE tt_ship.

DATA: gt_selected_rows TYPE lvc_t_row.

  • Custom container instance reference

DATA : g_control TYPE REF TO cl_gui_custom_container.

  • ALV Grid instance reference

DATA : g_alv TYPE REF TO cl_gui_alv_grid.

  • ALV list layout declaration

DATA : gs_layout TYPE lvc_s_layo.

  • Field catalog table

DATA : gt_fieldcat TYPE lvc_t_fcat.

START-OF-SELECTION.

DATA: ls_ship TYPE ts_ship.

SELECT vbeln ernam

FROM vbak

INTO TABLE gt_ship.

PERFORM fill_fieldcat CHANGING gt_fieldcat[].

  • &---------------------------------------------------------------------

*& Form fill_fieldcat

&----


  • text

----


  • <--P_GT_FIELDCAT[] text

----


FORM fill_fieldcat CHANGING ct_fieldcat TYPE lvc_t_fcat.

  • Local data

DATA : ls_fieldcat TYPE lvc_s_fcat.

REFRESH ct_fieldcat.

ls_fieldcat-fieldname = 'VBELN'.

ls_fieldcat-coltext = 'Order number'.

APPEND ls_fieldcat TO ct_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'ERNAM'.

ls_fieldcat-coltext = 'Name of Person'.

APPEND ls_fieldcat TO ct_fieldcat.

CLEAR ls_fieldcat.

ENDFORM. " fill_fieldcat

END-OF-SELECTION.

CALL SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'PF-0100'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module display OUTPUT

&----


  • text

----


MODULE display OUTPUT.

PERFORM set_windows_layout CHANGING gs_layout.

IF g_control IS INITIAL.

  • Create custom container object

CREATE OBJECT g_control

EXPORTING

container_name = 'ACTIVE_TEST'.

ENDIF.

  • ALV Grid instance reference

IF g_alv IS INITIAL.

CREATE OBJECT g_alv

EXPORTING

i_parent = g_control

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5

.

ENDIF.

      • Creating an instance for the event handler

    • CREATE OBJECT gv_event_handler .

  • Display grid via appropriate method of the grid object

CALL METHOD g_alv->set_table_for_first_display

EXPORTING

is_layout = gs_layout

CHANGING

it_outtab = gt_ship[]

it_fieldcatalog = gt_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

ENDMODULE. " display OUTPUT

&----


*& Module exit_program INPUT

&----


  • text

----


MODULE exit_program INPUT.

LEAVE TO SCREEN 0.

ENDMODULE. " exit_program INPUT

&----


*& Module user_command_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'BACK' .

LEAVE PROGRAM.

WHEN 'SELECT'.

  • get selected rows

REFRESH gt_selected_rows.

CALL METHOD g_alv->get_selected_rows

IMPORTING

et_index_rows = gt_selected_rows.

ENDCASE.

ENDMODULE. " user_command_0100 INPUT

&----


*& Form set_windows_layout

&----


  • text

----


  • <--P_GS_LAYOUT text

----


FORM set_windows_layout CHANGING cs_layout TYPE lvc_s_layo.

cs_layout-zebra = 'X'.

cs_layout-sel_mode = 'A'.

cs_layout-cwidth_opt = 'X'.

.

ENDFORM. " set_windows_layout

10 REPLIES 10
Read only

Former Member
0 Likes
1,024

hi Neha,

Can you please let us know the problem that you are encountering ??

Regards,

Santosh

Read only

0 Likes
1,024

hi

actually when i put the data declaration in include the it gives me error that statement select not accessable.n now its fine ...

but i want to put the data declaration in include...

plz help...

thnx

Message was edited by:

neha gupta

Read only

0 Likes
1,024

Hi,

Try activating the entire program[all includes and main program] at the same time.

Read only

0 Likes
1,024

create a include program in main program and copy the declarations into include it will work, do this if it doenst work i will give sample code

Read only

Former Member
0 Likes
1,024

whats the error ur facing

Read only

Former Member
0 Likes
1,024

hi Neha,

Put the declarations in an include and activate all the programs at the same time ..means while activating along with the main program check this program( Include ) too ..

Regards,

santosh

Read only

Former Member
0 Likes
1,024

Hi neha..take out all the data declaration statements.....

TYPES :

BEGIN OF ts_ship ,

vbeln TYPE vbak-vbeln , "order number

ernam TYPE vbak-ernam ,

END OF ts_ship ,

tt_ship TYPE TABLE OF ts_ship.

DATA : gt_ship TYPE tt_ship.

DATA: gt_selected_rows TYPE lvc_t_row.

  • Custom container instance reference

DATA : g_control TYPE REF TO cl_gui_custom_container.

  • ALV Grid instance reference

DATA : g_alv TYPE REF TO cl_gui_alv_grid.

  • ALV list layout declaration

DATA : gs_layout TYPE lvc_s_layo.

  • Field catalog table

DATA : gt_fieldcat TYPE lvc_t_fcat.

DATA: ls_ship TYPE ts_ship.

DATA : ls_fieldcat TYPE lvc_s_fcat.

put these in another program of type include program..save check activate....

now in the main program give the include statement

include <include name> at the top.

save check activate..this should solve the problem coz it worked at my end...

hope this helps,

all the best,

sampath

*mark helpful answers

Read only

Former Member
0 Likes
1,024

Thanks for the code C u again

Read only

Former Member
0 Likes
1,024

thnx

Read only

Former Member
0 Likes
1,024

hi,

create a include with all the data declarations and declare that include in the main program and activate the includes as well as main program.