Application Development 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: 

alv

Former Member
0 Kudos
149

If I have a report generated from a selection screen , and the user further wants to perform operations on the result , by entering a value on the report screen , can this be done using ALV or is dialog programming the only alternative.

An example using ALV to input and perform validations in the report screen will be very useful.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
106

Yes ,you can use Normal ALV as well ABAP Objects.

See the example one and here i am using ztable.

type-pools : slis.

tables : zsdcarton,

ztruck,

zwm_trk_loc,

zwm_trk_text.

  • Internal table for ZTRUCK and ZSDCARTON

data : begin of int_ztruck occurs 0 ,

vdatu like ztruck-vdatu,

ZZTRKNO like ztruck-ZZTRKNO,

  • zzrun like ztruck-zzrun,

ZZPHYTRK like ztruck-ZZPHYTRK,

zzdestime like ztruck-zzdestime,

zzrun like ztruck-zzrun,

ZZDEPTIME like ztruck-zzdeptime,

ZZSWAVENO like zsdcarton-ZZSWAVENO,

end of int_ztruck.

  • Internal table for ZSDCARTON

data : begin of i_zsdcarton occurs 0,

werks like zsdcarton-werks,

VDATU like zsdcarton-vdatu,

ZZRUN like zsdcarton-zzrun,

ZZSWAVENO like zsdcarton-ZZSWAVENO,

ZZTRKNO like zsdcarton-ZZTRKNO,

VBELN like zsdcarton-vbeln,

ZZCARTON like zsdcarton-zzcarton,

end of i_zsdcarton.

  • Final Internal Table

data : begin of i_final occurs 0,

sel_recs(1) type c,

vdatu like ztruck-vdatu,

ZZTRKNO like ZWMTRK_ALV-ZZTRKNO,

ZZPHYTRK like ztruck-ZZPHYTRK,

ZZSWAVENO like zsdcarton-ZZSWAVENO,

ZZDEPTIME like ztruck-ZZDEPTIME,

tord(5) type c,

tcart(5) type c,

zzdestime like ztruck-zzdestime,

ZZPLOC like zwm_trk_text-zztext,

ZZRLOC like zwm_trk_text-ZZtext,

zzrun like ztruck-zzrun,

name like zwm_trk_loc-name,

end of i_final.

  • Work Area for Truck Location table

data: w_trk_loc like zwm_trk_loc,

wm_text like zwm_trk_text.

  • Variables

data : v_lines type i,

v_lines1 type i,

v_repid like sy-repid.

  • ALV Function Module Variables

DATA: g_repid like sy-repid,

gs_layout type slis_layout_alv,

g_exit_caused_by_caller,

gs_exit_caused_by_user type slis_exit_by_user.

DATA: gt_fieldcat type slis_t_fieldcat_alv,

gs_print type slis_print_alv,

gt_events type slis_t_event,

gt_list_top_of_page type slis_t_listheader,

g_status_set type slis_formname value 'STANDARD_02',

g_user_command type slis_formname value 'USER_COMMAND',

g_top_of_page type slis_formname value 'TOP_OF_PAGE',

g_top_of_list type slis_formname value 'TOP_OF_LIST',

g_end_of_list type slis_formname value 'END_OF_LIST',

g_variant LIKE disvariant,

g_save(1) TYPE c,

g_tabname_header TYPE slis_tabname,

g_tabname_item TYPE slis_tabname,

g_exit(1) TYPE c,

gx_variant LIKE disvariant.

************************************************************************

                                • S E L E C T I O N - S C R E E N *********************

************************************************************************

selection-screen : begin of block blk with frame title text-001.

parameters : p_werks like ztruck-werks obligatory default '1000'.

parameters : p_vdatu like zsdcarton-vdatu obligatory ."default sy-datum.

select-options : s_run for ztruck-ZZRUN,

s_wave for ZSDCARTON-ZZSWAVENO ,

s_trkno for ZSDCARTON-ZZTRKNO.

selection-screen : end of block blk.

  • Fill the default values

initialization.

v_repid = sy-repid.

PERFORM LAYOUT_INIT USING GS_LAYOUT.

PERFORM EVENTTAB_BUILD USING GT_EVENTS[].

************************************************************************

                                • S T A R T - O F - S E L E C T I O N ***************

************************************************************************

start-of-selection.

  • Refresh and Clear all Variables and Internal Tables

perform clear_initial_values.

  • Get the data from ZTRUCK,ZSDCARTON,ZWVBAK and ZWVBAP

perform get_data_tables.

************************************************************************

                                    • E N D - O F - S E L E C T I O N *****************

************************************************************************

end-of-selection.

if not i_final[] is initial.

  • ALV Function Module

perform print_alv.

endif.

&----


*& Form clear_initial_values

&----


*

----


FORM clear_initial_values.

clear : i_zsdcarton,

int_ztruck,

v_lines,

v_lines1.

refresh : i_zsdcarton,

int_ztruck.

ENDFORM. " clear_initial_values

&----


*& Form get_data_tables

&----


  • Get the data from tables

----


FORM get_data_tables.

select a~vdatu a~ZZTRKNO a~ZZPHYTRK a~zzdestime

a~zzrun a~ZZDEPTIME b~ZZSWAVENO

into table int_ztruck

from ztruck as a inner join zsdcarton as b

on a~zztrkno = b~zztrkno

where a~vdatu = p_vdatu

and a~zztrkno in s_trkno

and b~ZZSWAVENO in s_wave

and a~zzrun in s_run

and b~zzrun in s_run

and a~werks = p_werks

and b~werks = p_werks

and b~vdatu = p_vdatu.

if sy-subrc ne 0.

message e004.

endif.

sort int_ztruck by vdatu zztrkno zzrun zzswaveno ZZPHYTRK .

DELETE ADJACENT DUPLICATES FROM int_ztruck

comparing vdatu zzrun zztrkno zzswaveno ZZPHYTRK.

loop at int_ztruck.

  • Get the data from ZSDCARTON

clear : i_zsdcarton,

v_lines,

v_lines1,

w_trk_loc,

wm_text.

refresh : i_zsdcarton.

select werks

vdatu

zzrun

ZZSWAVENO

ZZTRKNO

vbeln

ZZCARTON from zsdcarton into table i_zsdcarton

where werks = p_werks

and vdatu = int_ztruck-vdatu

and zzrun = int_ztruck-zzrun

and zztrkno = int_ztruck-zztrkno

and ZZSWAVENO = int_ztruck-ZZSWAVENO.

if sy-subrc eq 0.

  • Total Cartons

describe table i_zsdcarton lines v_lines.

i_final-tcart = v_lines.

DELETE ADJACENT DUPLICATES FROM i_zsdcarton

comparing werks vdatu zzrun zzswaveno vbeln.

  • Total Orders

describe table i_zsdcarton lines v_lines1.

i_final-tord = v_lines1.

endif.

  • Get the Parked Location and Returned Location.

select single * from zwm_trk_loc into w_trk_loc

where ZZPHYTRK = int_ztruck-ZZPHYTRK

and vdatu = int_ztruck-vdatu

and zztrkno = int_ztruck-zztrkno.

*

  • Get the Location Text from ZWM_TRK_TEXT Table

if sy-subrc eq 0.

select single * from zwm_trk_text into wm_text

where zzploc = w_trk_loc-zzploc.

if sy-subrc eq 0.

i_final-ZZPLOC = wm_text-zztext.

endif.

clear wm_text.

select single * from zwm_trk_text into wm_text

where zzploc = w_trk_loc-zzrloc.

if sy-subrc eq 0.

i_final-ZZrLOC = wm_text-zztext..

endif.

i_final-name = w_trk_loc-name.

endif.

i_final-vdatu = int_ztruck-vdatu.

i_final-zztrkno = int_ztruck-zztrkno.

i_final-ZZPHYTRK = int_ztruck-ZZPHYTRK.

i_final-ZZSWAVENO = int_ztruck-ZZSWAVENO.

i_final-zzdestime = int_ztruck-zzdestime.

i_final-zzrun = int_ztruck-zzrun.

i_final-ZZDEPTIME = int_ztruck-ZZDEPTIME.

append i_final.

clear : i_final,

int_ztruck.

endloop.

ENDFORM. " get_data_tables

----


  • FORM LAYOUT_INIT *

----


  • ........ *

----


  • --> RS_LAYOUT *

----


FORM LAYOUT_INIT USING RS_LAYOUT TYPE SLIS_LAYOUT_ALV.

**"Build layout for list display

RS_LAYOUT-DETAIL_POPUP = 'X'.

*

    • lslayout-f2code = p_f2code.

  • rs_layout-zebra = 'X'.

  • rs_layout-colwidth_optimize = 'X'.

ENDFORM.

----


  • FORM EVENTTAB_BUILD *

----


  • ........ *

----


  • --> RT_EVENTS *

----


FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.

*"Registration of events to happen during list display

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

*

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = RT_EVENTS.

READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO RT_EVENTS.

ENDIF.

ENDFORM.

&----


*& Form print_alv

&----


  • text

----


FORM print_alv.

sort i_final by ZZSWAVENO ZZDEPTIME.

PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

  • Populate field catalog

PERFORM fieldcat_init using gt_fieldcat[].

  • sort i_final

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = v_repid

I_CALLBACK_PF_STATUS_SET = 'STANDARD_02'

I_CALLBACK_USER_COMMAND = g_user_command

I_CALLBACK_TOP_OF_PAGE = g_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 = gs_layout

IT_FIELDCAT = gt_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = GT_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_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IT_EXCEPT_QINFO =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = i_final

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. " print_alv

----


  • FORM COMMENT_BUILD *

----


  • ........ *

----


  • --> LT_TOP_OF_PAGE *

----


FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE

SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

  • Variables for Date

data : lv_year(4) type c,

lv_mon(2) type c,

lv_day(2) type c,

lv_date1(10) type c,

lv_date2(10) type c,

lv_time(8) type c,

lv_hour(2) type c,

lv_min(2) type c,

lv_sec(2) type c.

  • LIST HEADING LINE: TYPE H

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

LS_LINE-INFO = sy-title.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • Plant

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-c02.

LS_LINE-INFO = P_WERKS.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

clear : lv_time,

lv_hour,

lv_min,

lv_sec.

lv_hour = sy-uzeit+0(2).

lv_min = sy-uzeit+2(2).

lv_sec = sy-uzeit+4(2).

concatenate lv_hour ':' lv_min ':' lv_sec into lv_time.

  • Current time

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-c03.

LS_LINE-INFO = lv_time.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

clear : lv_year,

lv_day,

lv_mon,

lv_date1.

lv_year = p_vdatu+0(4).

lv_mon = p_vdatu+4(2).

lv_day = p_vdatu+6(2).

concatenate lv_mon '/' lv_day '/' lv_year into lv_date1.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-c01.

LS_LINE-INFO = lv_date1.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

ENDFORM.

  • Fieldcatlog

FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR gs_layout.

gs_layout-f2code = ' '.

  • g_layout-flexible_key = 'X'.

  • g_layout-colwidth_optimize = 'X'.

gs_layout-detail_initial_lines = 'X'.

gs_layout-box_fieldname = 'SEL_RECS'.

gs_layout-box_tabname = 'ITAB_REPORT'.

  • Date

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'VDATU'.

LS_FIELDCAT-ref_fieldname = 'VDATU'.

LS_FIELDCAT-ref_tabname = 'ZTRUCK'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-no_out = 'X'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Route Number

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZTRKNO'.

LS_FIELDCAT-ref_fieldname = 'ZZTRKNO'.

LS_FIELDCAT-ref_tabname = 'ZTRUCK'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

  • ls_fieldcat-edit = 'X'.

  • LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Route Number'.

  • ls_fieldcat-seltext_M = 'Route Number'.

  • ls_fieldcat-seltext_S = 'Route Number'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Physical Truck

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZPHYTRK'.

  • LS_FIELDCAT-ref_fieldname = 'ZZPHYTRK'.

  • LS_FIELDCAT-ref_tabname = 'ZTRUCK'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

ls_fieldcat-edit = 'X'.

LS_FIELDCAT-OUTPUTLEN = 35.

ls_fieldcat-seltext_L = 'Physical Truck'.

  • ls_fieldcat-seltext_M = 'Physical Truck'.

  • ls_fieldcat-seltext_S = 'Physical Truck'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Wave

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZSWAVENO'.

  • LS_FIELDCAT-ref_fieldname = 'ZZSWAVENO'.

  • LS_FIELDCAT-ref_tabname = 'ZSDCARTON'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 10.

ls_fieldcat-seltext_L = 'Wave'.

  • ls_fieldcat-seltext_M = 'Wave'.

  • ls_fieldcat-seltext_S = 'Wave'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZDEPTIME'.

  • LS_FIELDCAT-ref_fieldname = 'ZZSWAVENO'.

  • LS_FIELDCAT-ref_tabname = 'ZSDCARTON'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 10.

ls_fieldcat-no_out = 'X'.

ls_fieldcat-seltext_L = 'Wave'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Total Orders

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'TORD'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 15.

ls_fieldcat-seltext_L = 'Total Orders'.

  • ls_fieldcat-seltext_M = 'Total Orders'.

  • ls_fieldcat-seltext_S = 'Total Orders'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Cartons Packed

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'TCART'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 15.

ls_fieldcat-seltext_L = 'Cartons Packed'.

  • ls_fieldcat-seltext_M = 'Cartons Packed'.

  • ls_fieldcat-seltext_S = 'Cartons Packed'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • First DI Time

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZDESTIME'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 15.

ls_fieldcat-seltext_L = 'First DI Time'.

  • ls_fieldcat-seltext_M = 'First DI Time'.

  • ls_fieldcat-seltext_S = 'First DI Time'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Parked Location

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZPLOC'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Parked Location'.

ls_fieldcat-edit = 'X'.

  • ls_fieldcat-seltext_M = 'Parked Location'.

  • ls_fieldcat-seltext_S = 'Parked Location'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Returned Location

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZRLOC'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Returned Location'.

ls_fieldcat-edit = 'X'.

  • ls_fieldcat-seltext_M = 'Returned Location'.

  • ls_fieldcat-seltext_S = 'Returned Location'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Wave Run

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZRUN'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

LS_FIELDCAT-NO_OUT = 'X'.

ls_fieldcat-seltext_L = 'Wave Run'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Wave Run

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'NAME'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Name'.

ls_fieldcat-edit = 'X'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

ENDFORM. " get_fieldcatlog

----


  • FORM TOP_OF_PAGE *

----


  • ........ *

----


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

I_LOGO = 'FDTRAN1'

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

ENDFORM.

----


  • FORM standard_02 *

----


  • ........ *

----


  • --> EXTAB *

----


FORM standard_02 USING extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD1'." EXCLUDING extab.

ENDFORM. "STANDARD_02

----


  • FORM USER_COMMAND *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield. "#EC CALLED

  • Local Variables

data : li_ztruck like ztruck occurs 0 with header line,

lv_zzphytrk like ZPHYSICAL_TRUCK-zzphytrk,

li_ZWM_TRK_LOC like ZWM_TRK_LOC occurs 0 with header line.

data : wa_loc like zwm_trk_text,

wa_text like zwm_trk_text,

lwa_ztruck like ztruck.

clear : li_ztruck,

lv_zzphytrk,

li_ZWM_TRK_LOC.

refresh : li_ztruck,

li_ZWM_TRK_LOC.

CASE R_UCOMM.

WHEN 'DISP'.

call transaction 'ZWM_TRK_LOC'.

when '&DATA_SAVE'.

loop at i_final.

clear lwa_ztruck.

  • Validate the Physical Truck #

select single zzphytrk from ZPHYSICAL_TRUCK into lv_zzphytrk

where zzphytrk = i_final-zzphytrk

and werks = p_werks

and lgnum = '100'.

if sy-subrc ne 0.

MESSAGE E090 WITH i_final-zzphytrk.

else.

  • Get the data from ztruck table

select single * from ztruck into lwa_ztruck

where werks = P_WERKS

and vdatu = P_VDATU

and zztrkno = i_final-zztrkno

and zzrun = i_final-zzrun.

if sy-subrc eq 0.

move lwa_ztruck to li_ztruck.

li_ztruck-ZZPHYTRK = i_final-ZZPHYTRK.

append li_ztruck.

CLEAR LI_ZTRUCK.

endif.

endif.

  • TRUCK LOCATION DETAILS

  • Location Validation

  • Parking Location Validation

clear: wa_loc,

wa_text.

  • Validation on Parked location

clear: wa_loc,

wa_text.

if i_final-zzploc is initial.

else.

select single * from zwm_trk_text into wa_text

where zzploc = i_final-zzploc.

if sy-subrc ne 0.

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzploc.

if sy-subrc ne 0.

message e091 with i_final-zzphytrk.

else.

move wa_text-zztext to i_final-zzploc.

endif.

else.

move wa_text-zztext to i_final-zzploc.

endif.

endif.

  • Validation on Returned Location

clear: wa_loc,

wa_text.

if i_final-zzrloc is initial.

else.

select single * from zwm_trk_text into wa_text

where zzploc = i_final-zzrloc.

if sy-subrc ne 0.

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzrloc.

if sy-subrc ne 0.

message e092 with i_final-zzphytrk.

else.

move wa_text-zztext to i_final-zzrloc.

endif.

else.

move wa_text-zztext to i_final-zzrloc.

endif.

endif.

modify i_final.

clear wa_text.

  • Parked Location

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzploc.

if sy-subrc eq 0.

move wa_text-zzploc to li_ZWM_TRK_LOC-zzploc.

endif.

clear wa_text.

  • Returned Location

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzrloc.

if sy-subrc eq 0.

move wa_text-zzploc to li_ZWM_TRK_LOC-zzrloc.

endif.

li_zwm_trk_loc-zztrkno = i_final-zztrkno.

li_zwm_trk_loc-vdatu = i_final-vdatu.

li_ZWM_TRK_LOC-zzphytrk = i_final-zzphytrk.

li_zwm_trk_loc-name = i_final-name.

append li_ZWM_TRK_LOC.

clear li_ZWM_TRK_LOC.

endloop.

modify ztruck from table li_ztruck.

modify ZWM_TRK_LOC from table li_ZWM_TRK_LOC.

when 'ENT1'.

loop at i_final.

  • Validate the Physical Truck #

select single zzphytrk from ZPHYSICAL_TRUCK into lv_zzphytrk

where zzphytrk = i_final-zzphytrk

and werks = p_werks

and lgnum = '100'.

if sy-subrc ne 0.

MESSAGE E090 WITH i_final-zzphytrk.

else.

li_ztruck-werks = p_werks.

li_ztruck-vdatu = p_vdatu.

li_ztruck-zztrkno = i_final-zztrkno.

li_ztruck-ZZPHYTRK = i_final-ZZPHYTRK.

LI_ZTRUCK-ZZRUN = I_FINAL-ZZRUN.

append li_ztruck.

CLEAR LI_ZTRUCK.

endif.

  • TRUCK LOCATION DETAILS

li_ZWM_TRK_LOC-zzphytrk = i_final-zzphytrk.

if i_final-zzploc = 'RR' or i_final-zzploc = 'rr'.

i_final-zzploc = 'Rail Road Parking'.

elseif i_final-zzploc = 'UTB' or i_final-zzploc = 'utb'.

i_final-zzploc = 'Up The Block'.

elseif i_final-zzploc = 'PL' or i_final-zzploc = 'pl'.

i_final-zzploc = 'Apple Building'.

elseif i_final-zzploc = 'SH' or i_final-zzploc = 'sh'.

i_final-zzploc = 'Shipping Yard'.

elseif i_final-zzploc = 'BO' or i_final-zzploc = 'bo'.

i_final-zzploc = 'Borden Ave'.

elseif i_final-zzploc = '23' .

i_final-zzploc = '23rd Street'.

elseif i_final-zzploc = 'SW' or i_final-zzploc = 'sw'.

i_final-zzploc = 'Side Walk'.

else.

message e091 with i_final-zzphytrk.

endif.

li_zwm_trk_loc-vdatu = i_final-vdatu.

li_zwm_trk_loc-zztrkno = i_final-zztrkno.

li_ZWM_TRK_LOC-zzploc = i_final-zzploc.

li_ZWM_TRK_LOC-zzrloc = i_final-zzrloc.

append li_ZWM_TRK_LOC.

clear li_ZWM_TRK_LOC.

endloop.

ENDCASE.

ENDFORM.

Thanks

Seshu

5 REPLIES 5

Former Member
0 Kudos
107

Yes ,you can use Normal ALV as well ABAP Objects.

See the example one and here i am using ztable.

type-pools : slis.

tables : zsdcarton,

ztruck,

zwm_trk_loc,

zwm_trk_text.

  • Internal table for ZTRUCK and ZSDCARTON

data : begin of int_ztruck occurs 0 ,

vdatu like ztruck-vdatu,

ZZTRKNO like ztruck-ZZTRKNO,

  • zzrun like ztruck-zzrun,

ZZPHYTRK like ztruck-ZZPHYTRK,

zzdestime like ztruck-zzdestime,

zzrun like ztruck-zzrun,

ZZDEPTIME like ztruck-zzdeptime,

ZZSWAVENO like zsdcarton-ZZSWAVENO,

end of int_ztruck.

  • Internal table for ZSDCARTON

data : begin of i_zsdcarton occurs 0,

werks like zsdcarton-werks,

VDATU like zsdcarton-vdatu,

ZZRUN like zsdcarton-zzrun,

ZZSWAVENO like zsdcarton-ZZSWAVENO,

ZZTRKNO like zsdcarton-ZZTRKNO,

VBELN like zsdcarton-vbeln,

ZZCARTON like zsdcarton-zzcarton,

end of i_zsdcarton.

  • Final Internal Table

data : begin of i_final occurs 0,

sel_recs(1) type c,

vdatu like ztruck-vdatu,

ZZTRKNO like ZWMTRK_ALV-ZZTRKNO,

ZZPHYTRK like ztruck-ZZPHYTRK,

ZZSWAVENO like zsdcarton-ZZSWAVENO,

ZZDEPTIME like ztruck-ZZDEPTIME,

tord(5) type c,

tcart(5) type c,

zzdestime like ztruck-zzdestime,

ZZPLOC like zwm_trk_text-zztext,

ZZRLOC like zwm_trk_text-ZZtext,

zzrun like ztruck-zzrun,

name like zwm_trk_loc-name,

end of i_final.

  • Work Area for Truck Location table

data: w_trk_loc like zwm_trk_loc,

wm_text like zwm_trk_text.

  • Variables

data : v_lines type i,

v_lines1 type i,

v_repid like sy-repid.

  • ALV Function Module Variables

DATA: g_repid like sy-repid,

gs_layout type slis_layout_alv,

g_exit_caused_by_caller,

gs_exit_caused_by_user type slis_exit_by_user.

DATA: gt_fieldcat type slis_t_fieldcat_alv,

gs_print type slis_print_alv,

gt_events type slis_t_event,

gt_list_top_of_page type slis_t_listheader,

g_status_set type slis_formname value 'STANDARD_02',

g_user_command type slis_formname value 'USER_COMMAND',

g_top_of_page type slis_formname value 'TOP_OF_PAGE',

g_top_of_list type slis_formname value 'TOP_OF_LIST',

g_end_of_list type slis_formname value 'END_OF_LIST',

g_variant LIKE disvariant,

g_save(1) TYPE c,

g_tabname_header TYPE slis_tabname,

g_tabname_item TYPE slis_tabname,

g_exit(1) TYPE c,

gx_variant LIKE disvariant.

************************************************************************

                                • S E L E C T I O N - S C R E E N *********************

************************************************************************

selection-screen : begin of block blk with frame title text-001.

parameters : p_werks like ztruck-werks obligatory default '1000'.

parameters : p_vdatu like zsdcarton-vdatu obligatory ."default sy-datum.

select-options : s_run for ztruck-ZZRUN,

s_wave for ZSDCARTON-ZZSWAVENO ,

s_trkno for ZSDCARTON-ZZTRKNO.

selection-screen : end of block blk.

  • Fill the default values

initialization.

v_repid = sy-repid.

PERFORM LAYOUT_INIT USING GS_LAYOUT.

PERFORM EVENTTAB_BUILD USING GT_EVENTS[].

************************************************************************

                                • S T A R T - O F - S E L E C T I O N ***************

************************************************************************

start-of-selection.

  • Refresh and Clear all Variables and Internal Tables

perform clear_initial_values.

  • Get the data from ZTRUCK,ZSDCARTON,ZWVBAK and ZWVBAP

perform get_data_tables.

************************************************************************

                                    • E N D - O F - S E L E C T I O N *****************

************************************************************************

end-of-selection.

if not i_final[] is initial.

  • ALV Function Module

perform print_alv.

endif.

&----


*& Form clear_initial_values

&----


*

----


FORM clear_initial_values.

clear : i_zsdcarton,

int_ztruck,

v_lines,

v_lines1.

refresh : i_zsdcarton,

int_ztruck.

ENDFORM. " clear_initial_values

&----


*& Form get_data_tables

&----


  • Get the data from tables

----


FORM get_data_tables.

select a~vdatu a~ZZTRKNO a~ZZPHYTRK a~zzdestime

a~zzrun a~ZZDEPTIME b~ZZSWAVENO

into table int_ztruck

from ztruck as a inner join zsdcarton as b

on a~zztrkno = b~zztrkno

where a~vdatu = p_vdatu

and a~zztrkno in s_trkno

and b~ZZSWAVENO in s_wave

and a~zzrun in s_run

and b~zzrun in s_run

and a~werks = p_werks

and b~werks = p_werks

and b~vdatu = p_vdatu.

if sy-subrc ne 0.

message e004.

endif.

sort int_ztruck by vdatu zztrkno zzrun zzswaveno ZZPHYTRK .

DELETE ADJACENT DUPLICATES FROM int_ztruck

comparing vdatu zzrun zztrkno zzswaveno ZZPHYTRK.

loop at int_ztruck.

  • Get the data from ZSDCARTON

clear : i_zsdcarton,

v_lines,

v_lines1,

w_trk_loc,

wm_text.

refresh : i_zsdcarton.

select werks

vdatu

zzrun

ZZSWAVENO

ZZTRKNO

vbeln

ZZCARTON from zsdcarton into table i_zsdcarton

where werks = p_werks

and vdatu = int_ztruck-vdatu

and zzrun = int_ztruck-zzrun

and zztrkno = int_ztruck-zztrkno

and ZZSWAVENO = int_ztruck-ZZSWAVENO.

if sy-subrc eq 0.

  • Total Cartons

describe table i_zsdcarton lines v_lines.

i_final-tcart = v_lines.

DELETE ADJACENT DUPLICATES FROM i_zsdcarton

comparing werks vdatu zzrun zzswaveno vbeln.

  • Total Orders

describe table i_zsdcarton lines v_lines1.

i_final-tord = v_lines1.

endif.

  • Get the Parked Location and Returned Location.

select single * from zwm_trk_loc into w_trk_loc

where ZZPHYTRK = int_ztruck-ZZPHYTRK

and vdatu = int_ztruck-vdatu

and zztrkno = int_ztruck-zztrkno.

*

  • Get the Location Text from ZWM_TRK_TEXT Table

if sy-subrc eq 0.

select single * from zwm_trk_text into wm_text

where zzploc = w_trk_loc-zzploc.

if sy-subrc eq 0.

i_final-ZZPLOC = wm_text-zztext.

endif.

clear wm_text.

select single * from zwm_trk_text into wm_text

where zzploc = w_trk_loc-zzrloc.

if sy-subrc eq 0.

i_final-ZZrLOC = wm_text-zztext..

endif.

i_final-name = w_trk_loc-name.

endif.

i_final-vdatu = int_ztruck-vdatu.

i_final-zztrkno = int_ztruck-zztrkno.

i_final-ZZPHYTRK = int_ztruck-ZZPHYTRK.

i_final-ZZSWAVENO = int_ztruck-ZZSWAVENO.

i_final-zzdestime = int_ztruck-zzdestime.

i_final-zzrun = int_ztruck-zzrun.

i_final-ZZDEPTIME = int_ztruck-ZZDEPTIME.

append i_final.

clear : i_final,

int_ztruck.

endloop.

ENDFORM. " get_data_tables

----


  • FORM LAYOUT_INIT *

----


  • ........ *

----


  • --> RS_LAYOUT *

----


FORM LAYOUT_INIT USING RS_LAYOUT TYPE SLIS_LAYOUT_ALV.

**"Build layout for list display

RS_LAYOUT-DETAIL_POPUP = 'X'.

*

    • lslayout-f2code = p_f2code.

  • rs_layout-zebra = 'X'.

  • rs_layout-colwidth_optimize = 'X'.

ENDFORM.

----


  • FORM EVENTTAB_BUILD *

----


  • ........ *

----


  • --> RT_EVENTS *

----


FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.

*"Registration of events to happen during list display

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

*

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = RT_EVENTS.

READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO RT_EVENTS.

ENDIF.

ENDFORM.

&----


*& Form print_alv

&----


  • text

----


FORM print_alv.

sort i_final by ZZSWAVENO ZZDEPTIME.

PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

  • Populate field catalog

PERFORM fieldcat_init using gt_fieldcat[].

  • sort i_final

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = v_repid

I_CALLBACK_PF_STATUS_SET = 'STANDARD_02'

I_CALLBACK_USER_COMMAND = g_user_command

I_CALLBACK_TOP_OF_PAGE = g_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 = gs_layout

IT_FIELDCAT = gt_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = GT_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_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IT_EXCEPT_QINFO =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = i_final

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. " print_alv

----


  • FORM COMMENT_BUILD *

----


  • ........ *

----


  • --> LT_TOP_OF_PAGE *

----


FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE

SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

  • Variables for Date

data : lv_year(4) type c,

lv_mon(2) type c,

lv_day(2) type c,

lv_date1(10) type c,

lv_date2(10) type c,

lv_time(8) type c,

lv_hour(2) type c,

lv_min(2) type c,

lv_sec(2) type c.

  • LIST HEADING LINE: TYPE H

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

LS_LINE-INFO = sy-title.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • Plant

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-c02.

LS_LINE-INFO = P_WERKS.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

clear : lv_time,

lv_hour,

lv_min,

lv_sec.

lv_hour = sy-uzeit+0(2).

lv_min = sy-uzeit+2(2).

lv_sec = sy-uzeit+4(2).

concatenate lv_hour ':' lv_min ':' lv_sec into lv_time.

  • Current time

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-c03.

LS_LINE-INFO = lv_time.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

clear : lv_year,

lv_day,

lv_mon,

lv_date1.

lv_year = p_vdatu+0(4).

lv_mon = p_vdatu+4(2).

lv_day = p_vdatu+6(2).

concatenate lv_mon '/' lv_day '/' lv_year into lv_date1.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-c01.

LS_LINE-INFO = lv_date1.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = ''.

LS_LINE-INFO = ''.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

ENDFORM.

  • Fieldcatlog

FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR gs_layout.

gs_layout-f2code = ' '.

  • g_layout-flexible_key = 'X'.

  • g_layout-colwidth_optimize = 'X'.

gs_layout-detail_initial_lines = 'X'.

gs_layout-box_fieldname = 'SEL_RECS'.

gs_layout-box_tabname = 'ITAB_REPORT'.

  • Date

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'VDATU'.

LS_FIELDCAT-ref_fieldname = 'VDATU'.

LS_FIELDCAT-ref_tabname = 'ZTRUCK'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-no_out = 'X'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Route Number

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZTRKNO'.

LS_FIELDCAT-ref_fieldname = 'ZZTRKNO'.

LS_FIELDCAT-ref_tabname = 'ZTRUCK'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

  • ls_fieldcat-edit = 'X'.

  • LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Route Number'.

  • ls_fieldcat-seltext_M = 'Route Number'.

  • ls_fieldcat-seltext_S = 'Route Number'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Physical Truck

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZPHYTRK'.

  • LS_FIELDCAT-ref_fieldname = 'ZZPHYTRK'.

  • LS_FIELDCAT-ref_tabname = 'ZTRUCK'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

ls_fieldcat-edit = 'X'.

LS_FIELDCAT-OUTPUTLEN = 35.

ls_fieldcat-seltext_L = 'Physical Truck'.

  • ls_fieldcat-seltext_M = 'Physical Truck'.

  • ls_fieldcat-seltext_S = 'Physical Truck'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Wave

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZSWAVENO'.

  • LS_FIELDCAT-ref_fieldname = 'ZZSWAVENO'.

  • LS_FIELDCAT-ref_tabname = 'ZSDCARTON'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 10.

ls_fieldcat-seltext_L = 'Wave'.

  • ls_fieldcat-seltext_M = 'Wave'.

  • ls_fieldcat-seltext_S = 'Wave'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZDEPTIME'.

  • LS_FIELDCAT-ref_fieldname = 'ZZSWAVENO'.

  • LS_FIELDCAT-ref_tabname = 'ZSDCARTON'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 10.

ls_fieldcat-no_out = 'X'.

ls_fieldcat-seltext_L = 'Wave'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Total Orders

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'TORD'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 15.

ls_fieldcat-seltext_L = 'Total Orders'.

  • ls_fieldcat-seltext_M = 'Total Orders'.

  • ls_fieldcat-seltext_S = 'Total Orders'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Cartons Packed

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'TCART'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 15.

ls_fieldcat-seltext_L = 'Cartons Packed'.

  • ls_fieldcat-seltext_M = 'Cartons Packed'.

  • ls_fieldcat-seltext_S = 'Cartons Packed'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • First DI Time

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZDESTIME'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 15.

ls_fieldcat-seltext_L = 'First DI Time'.

  • ls_fieldcat-seltext_M = 'First DI Time'.

  • ls_fieldcat-seltext_S = 'First DI Time'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Parked Location

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZPLOC'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Parked Location'.

ls_fieldcat-edit = 'X'.

  • ls_fieldcat-seltext_M = 'Parked Location'.

  • ls_fieldcat-seltext_S = 'Parked Location'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Returned Location

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZRLOC'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Returned Location'.

ls_fieldcat-edit = 'X'.

  • ls_fieldcat-seltext_M = 'Returned Location'.

  • ls_fieldcat-seltext_S = 'Returned Location'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Wave Run

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'ZZRUN'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

LS_FIELDCAT-NO_OUT = 'X'.

ls_fieldcat-seltext_L = 'Wave Run'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Wave Run

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'NAME'.

LS_FIELDCAT-TABNAME = 'I_FINAL'.

LS_FIELDCAT-OUTPUTLEN = 25.

ls_fieldcat-seltext_L = 'Name'.

ls_fieldcat-edit = 'X'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

ENDFORM. " get_fieldcatlog

----


  • FORM TOP_OF_PAGE *

----


  • ........ *

----


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

I_LOGO = 'FDTRAN1'

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

ENDFORM.

----


  • FORM standard_02 *

----


  • ........ *

----


  • --> EXTAB *

----


FORM standard_02 USING extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD1'." EXCLUDING extab.

ENDFORM. "STANDARD_02

----


  • FORM USER_COMMAND *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield. "#EC CALLED

  • Local Variables

data : li_ztruck like ztruck occurs 0 with header line,

lv_zzphytrk like ZPHYSICAL_TRUCK-zzphytrk,

li_ZWM_TRK_LOC like ZWM_TRK_LOC occurs 0 with header line.

data : wa_loc like zwm_trk_text,

wa_text like zwm_trk_text,

lwa_ztruck like ztruck.

clear : li_ztruck,

lv_zzphytrk,

li_ZWM_TRK_LOC.

refresh : li_ztruck,

li_ZWM_TRK_LOC.

CASE R_UCOMM.

WHEN 'DISP'.

call transaction 'ZWM_TRK_LOC'.

when '&DATA_SAVE'.

loop at i_final.

clear lwa_ztruck.

  • Validate the Physical Truck #

select single zzphytrk from ZPHYSICAL_TRUCK into lv_zzphytrk

where zzphytrk = i_final-zzphytrk

and werks = p_werks

and lgnum = '100'.

if sy-subrc ne 0.

MESSAGE E090 WITH i_final-zzphytrk.

else.

  • Get the data from ztruck table

select single * from ztruck into lwa_ztruck

where werks = P_WERKS

and vdatu = P_VDATU

and zztrkno = i_final-zztrkno

and zzrun = i_final-zzrun.

if sy-subrc eq 0.

move lwa_ztruck to li_ztruck.

li_ztruck-ZZPHYTRK = i_final-ZZPHYTRK.

append li_ztruck.

CLEAR LI_ZTRUCK.

endif.

endif.

  • TRUCK LOCATION DETAILS

  • Location Validation

  • Parking Location Validation

clear: wa_loc,

wa_text.

  • Validation on Parked location

clear: wa_loc,

wa_text.

if i_final-zzploc is initial.

else.

select single * from zwm_trk_text into wa_text

where zzploc = i_final-zzploc.

if sy-subrc ne 0.

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzploc.

if sy-subrc ne 0.

message e091 with i_final-zzphytrk.

else.

move wa_text-zztext to i_final-zzploc.

endif.

else.

move wa_text-zztext to i_final-zzploc.

endif.

endif.

  • Validation on Returned Location

clear: wa_loc,

wa_text.

if i_final-zzrloc is initial.

else.

select single * from zwm_trk_text into wa_text

where zzploc = i_final-zzrloc.

if sy-subrc ne 0.

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzrloc.

if sy-subrc ne 0.

message e092 with i_final-zzphytrk.

else.

move wa_text-zztext to i_final-zzrloc.

endif.

else.

move wa_text-zztext to i_final-zzrloc.

endif.

endif.

modify i_final.

clear wa_text.

  • Parked Location

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzploc.

if sy-subrc eq 0.

move wa_text-zzploc to li_ZWM_TRK_LOC-zzploc.

endif.

clear wa_text.

  • Returned Location

select single * from zwm_trk_text into wa_text

where zztext = i_final-zzrloc.

if sy-subrc eq 0.

move wa_text-zzploc to li_ZWM_TRK_LOC-zzrloc.

endif.

li_zwm_trk_loc-zztrkno = i_final-zztrkno.

li_zwm_trk_loc-vdatu = i_final-vdatu.

li_ZWM_TRK_LOC-zzphytrk = i_final-zzphytrk.

li_zwm_trk_loc-name = i_final-name.

append li_ZWM_TRK_LOC.

clear li_ZWM_TRK_LOC.

endloop.

modify ztruck from table li_ztruck.

modify ZWM_TRK_LOC from table li_ZWM_TRK_LOC.

when 'ENT1'.

loop at i_final.

  • Validate the Physical Truck #

select single zzphytrk from ZPHYSICAL_TRUCK into lv_zzphytrk

where zzphytrk = i_final-zzphytrk

and werks = p_werks

and lgnum = '100'.

if sy-subrc ne 0.

MESSAGE E090 WITH i_final-zzphytrk.

else.

li_ztruck-werks = p_werks.

li_ztruck-vdatu = p_vdatu.

li_ztruck-zztrkno = i_final-zztrkno.

li_ztruck-ZZPHYTRK = i_final-ZZPHYTRK.

LI_ZTRUCK-ZZRUN = I_FINAL-ZZRUN.

append li_ztruck.

CLEAR LI_ZTRUCK.

endif.

  • TRUCK LOCATION DETAILS

li_ZWM_TRK_LOC-zzphytrk = i_final-zzphytrk.

if i_final-zzploc = 'RR' or i_final-zzploc = 'rr'.

i_final-zzploc = 'Rail Road Parking'.

elseif i_final-zzploc = 'UTB' or i_final-zzploc = 'utb'.

i_final-zzploc = 'Up The Block'.

elseif i_final-zzploc = 'PL' or i_final-zzploc = 'pl'.

i_final-zzploc = 'Apple Building'.

elseif i_final-zzploc = 'SH' or i_final-zzploc = 'sh'.

i_final-zzploc = 'Shipping Yard'.

elseif i_final-zzploc = 'BO' or i_final-zzploc = 'bo'.

i_final-zzploc = 'Borden Ave'.

elseif i_final-zzploc = '23' .

i_final-zzploc = '23rd Street'.

elseif i_final-zzploc = 'SW' or i_final-zzploc = 'sw'.

i_final-zzploc = 'Side Walk'.

else.

message e091 with i_final-zzphytrk.

endif.

li_zwm_trk_loc-vdatu = i_final-vdatu.

li_zwm_trk_loc-zztrkno = i_final-zztrkno.

li_ZWM_TRK_LOC-zzploc = i_final-zzploc.

li_ZWM_TRK_LOC-zzrloc = i_final-zzrloc.

append li_ZWM_TRK_LOC.

clear li_ZWM_TRK_LOC.

endloop.

ENDCASE.

ENDFORM.

Thanks

Seshu

0 Kudos
106

i Get a runtime error where it says the internal table passes to field catalog marge has a different structure . What could be the problem.

0 Kudos
106

Issue would be fieldcatalog .. Please pass what ever structure you have internal table..

if not then paste your code and do you have any custom table in report ?

Thanks

Seshu

0 Kudos
106

Thank you Seshu

0 Kudos
106

Follow the next steps:

Note: it's an example and contains errors

1. Make a class with the events handler for Data Changed :

CLASS lcl_evento DEFINITION.

PUBLIC SECTION.

METHODS:

handle_data_changed

FOR EVENT data_changed OF cl_gui_alv_grid

IMPORTING er_data_changed.

ENDCLASS. "lcl_evento DEFINITION

CLASS lcl_evento IMPLEMENTATION.

METHOD handle_data_changed.

DATA: ls_good TYPE lvc_s_modi,

w_value TYPE mard-labst.

LOOP AT er_data_changed->mt_good_cells INTO ls_good.

CLEAR wa_despacho_alv.

READ TABLE itab INDEX ls_good-row_id INTO wa_despacho_alv.

CASE ls_good-fieldname.

WHEN 'COLUMN_1'.

PERFORM validate_COLUMN_1.

WHEN 'COLUMN_2'.

PERFORM validate_COLUMN_2.

ENDCASE.

wa_despacho_alv-usuario = sy-uname.

wa_despacho_alv-fecha_registro = sy-datum.

MODIFY it_despacho_alv INDEX ls_good-row_id FROM wa_despacho_alv.

CALL METHOD alv_despacho_dy2100->get_current_cell

IMPORTING

es_row_id = r_cell_row

es_col_id = r_cell_col.

CALL METHOD alv_despacho_dy2100->refresh_table_display.

CALL METHOD alv_despacho_dy2100->set_current_cell_via_id

EXPORTING

is_row_id = r_cell_row

is_column_id = r_cell_col.

ENDLOOP.

ENDMETHOD. "handle_data_changed

ENDCLASS. "lcl_evento IMPLEMENTATION

2. create object:

data: ob_event TYPE REF TO lcl_evento

CREATE OBJECT ob_event.

3. Create ALV (use cl_gui_alv_grid)

DATA: ob_alv TYPE REF TO cl_gui_alv_grid.

...

perform create_layout.

...

perform create_fieldcat.

...

5. set colums editable with the fieldcat:

gs_fieldcat-fieldname = 'COLUMN_1'.

gs_fieldcat-edit = 'X'.

append gs_fieldcat to gt_fieldcat.

gs_fieldcat-fieldname = 'COLUMN_2'.

gs_fieldcat-edit = 'X'.

append gs_fieldcat to gt_fieldcat.

gs_fieldcat-fieldname = 'COLUMN_3'.

gs_fieldcat-edit = ''.

append gs_fieldcat to gt_fieldcat.

4. Active Handlers for alv object

CALL METHOD ob_alv->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

  • Set editable cells to ready for input

CALL METHOD ob_alv->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

5. Display ALV.