Skip to Content
0
Former Member
Sep 13, 2007 at 09:21 AM

regarding report

19 Views

hi experts,

m tryin to execute an alv report,,but when user tries to intract with this by clickin on roll no,article no,etc it is not showing any data,..m sending u the code..plz check it once n tell me what is the problem...

report zsd_r_report.

&----


*& Type-Pools

&----


type-pools: slis.

----


  • Table Declaration *

----


tables : vbrk, " Billing Document Header

vbrp, "Billing Document: Item Data

qals,

qamv.

----


  • DECLARATION OF TYPES *

----


data : t_vbrk type vbrk,

t_vbrp type vbrp,

t_lips type lips,

t_qals type qals,

t_qamv type qamv.

types : begin of t_vbrk,

vbeln type vbrk-vbeln,

knumv type vbrk-knumv,

waerk type vbrk-waerk,

end of t_vbrk,

begin of t_vbrp,

vbeln type vbrp-vbeln,

matnr type vbrp-matnr,

posnr type vbrp-posnr,

vgbel type vbrp-vgbel,

vgpos type vbrp-vgpos,

end of t_vbrp,

begin of t_lips,

vbeln type lips-vbeln,

posnr type lips-posnr,

matnr type lips-matnr,

charg type lips-charg,

werks type lips-werks,

uecha type lips-uecha,

end of t_lips,

begin of t_qals,

prueflos type qals-prueflos,

werk type qals-werk,

matnr type qals-matnr,

charg type qals-charg,

end of t_qals,

begin of t_qamv ,

prueflos type qals-prueflos,

vorglfnr type qapp-vorglfnr,

merknr type qamv-merknr,

verwmerkm type qamv-verwmerkm,

  • matnr type qamv-matnr,

end of t_qamv,

begin of t_qamr,

prueflos type qamr-prueflos,

vorglfnr type qamr-vorglfnr,

merknr type qamr-merknr,

original_input type qamr-original_input,

end of t_qamr.

----


  • DECLARATION OF INTERNAL TABLES *

----


data : i_vbrk type standard table of t_vbrk,

i_vbrp type standard table of t_vbrp,

i_lips type standard table of t_lips,

i_qals type standard table of t_qals,

i_qamv type standard table of t_qamv,

i_qamr type standard table of t_qamr.

data : begin of it_final occurs 0,

count type i,

atwrt type cawn-atwrt,

vbeln type vbrp-vbeln,

artno type vbrp-matnr,

matnr type vbrp-matnr,

posnr type vbrp-posnr,

vgbel type vbrp-vgbel,

vgpos type vbrp-vgpos,

charg type qals-charg,

uecha type lips-uecha,

werks type lips-werks,

prueflos type qals-prueflos,

vorglfnr type qapp-vorglfnr,

merknr type qamv-merknr,

verwmerkm type qamv-verwmerkm,

act_mtrs type qamr-original_input,

t_points type qamr-original_input,

t_flags type qamr-original_input,

q_weight type qamr-original_input,

throw type qamr-original_input,

yards type qamr-original_input,

end of it_final.

data : begin of shade occurs 0,

atwrt type cawn-atwrt,

end of shade.

----


  • DECLARATION OF WORK AREAS *

----


data : wa_vbrk type t_vbrk,

wa_vbrp type t_vbrp,

wa_lips type t_lips,

wa_qals type t_qals,

wa_qamv type t_qamv,

wa_qamr type t_qamr,

wa_shade like line of shade,

wa_final like line of it_final.

&----


*& ALV Declarations

&----


data : gs_fcat type slis_t_fieldcat_alv,

gs_layout type slis_layout_alv,

gs_events type slis_t_event,

gs_listheader type slis_t_listheader.

&----


*& Constants

&----


constants : c_x type c value 'X',

c_repid type sy-repid value 'ZROLL_PACK'.

----


  • DECLARATION OF SELECTION SCREEN *

----


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

parameters: p_vbeln like vbrk-vbeln obligatory.

selection-screen end of block blk.

----


  • AT SELECTION SCREEN event *

----


at selection-screen.

if p_vbeln is not initial.

perform check_vbeln.

endif.

&----


*& Start-Of-Selection

&----


start-of-selection.

*-- Perform get data

perform get_data.

*-- Process data

perform process_data.

*-- Build Fieldcatalog.

perform field_cat using gs_fcat.

*-- Layout

perform layout.

*-- List header

perform list_header using gs_listheader.

*-- ALV Events

perform alv_events using gs_events.

*-- Display Data

perform display_data.

&----


*& Form check_VBELN

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form check_vbeln .

select single * from vbrk into t_vbrk

where vbeln eq p_vbeln.

if sy-subrc ne 0.

message 'No Data Found for the Selection Criteria' type 'E'.

endif. " if sy-subrc ne 0.

endform. " check_VBELN

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

*For Customer Material Number

select vbeln

matnr

vgbel

posnr

vgpos

from vbrp

into corresponding fields of table i_vbrp

where vbeln eq p_vbeln.

select vbeln

posnr

matnr

charg

uecha

werks from lips into corresponding fields of table i_lips

for all entries in i_vbrp

where vbeln = i_vbrp-vgbel

and charg ne space.

*----For Inspection Lot No, Mat No,Batch and plant

select prueflos

werk

charg

matnr from qals into corresponding fields of table i_qals

for all entries in i_lips

where matnr = i_lips-matnr

and charg = i_lips-charg.

**---For Actual Meters ,Throw,point gross_wt and other details

select prueflos

vorglfnr

  • PROBENR

merknr

verwmerkm

from qamv

into corresponding fields of table i_qamv

for all entries in i_qals

where prueflos = i_qals-prueflos.

*----For meter values

select prueflos

vorglfnr

merknr

original_input

from qamr

into corresponding fields of table i_qamr

for all entries in i_qamv

where prueflos = i_qamv-prueflos

and vorglfnr = i_qamv-vorglfnr

and merknr = i_qamv-merknr.

read table i_lips into wa_lips index 1.

select single atwrt

from ausp

into shade "Shade Number

where objek = wa_lips-matnr

and atinn = '0000001150'.

append shade.

  • CLEAR shade.

  • endselect.

  • ENDLOOP.

endform. " get_data

&----


*& Form process_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form process_data .

loop at i_lips into wa_lips.

move : wa_lips-matnr to wa_final-matnr,

wa_lips-matnr+3(4) to wa_final-artno,

wa_lips-charg to wa_final-charg,

wa_lips-uecha to wa_final-uecha,

shade-atwrt to wa_final-atwrt,

sy-tabix to wa_final-count.

read table i_qals into wa_qals with key matnr = wa_lips-matnr

charg = wa_lips-charg.

if sy-subrc is initial.

read table i_qamv into wa_qamv

with key prueflos = wa_qals-prueflos .

  • charg = wa_qals-charg.

loop at i_qamv into wa_qamv ."WHERE prueflos = wa_qamv-prueflos.

  • AND vorglfnr = wa_qamv-vorglfnr

  • AND merknr = wa_qamv-merknr.

case wa_qamv-verwmerkm.

when 'ACT_MTRS'.

read table i_qamr into wa_qamr with key

prueflos = wa_qamv-prueflos

vorglfnr = wa_qamv-vorglfnr

merknr = wa_qamv-merknr.

wa_final-act_mtrs = wa_qamr-original_input.

when 'T_POINTS'.

read table i_qamr into wa_qamr with key

prueflos = wa_qamv-prueflos

vorglfnr = wa_qamv-vorglfnr

merknr = wa_qamv-merknr.

wa_final-t_points = wa_qamr-original_input.

when 'T_FLAGS'.

read table i_qamr into wa_qamr with key

prueflos = wa_qamv-prueflos

vorglfnr = wa_qamv-vorglfnr

merknr = wa_qamv-merknr.

wa_final-t_flags = wa_qamr-original_input.

when 'Q_WEIGHT'.

read table i_qamr into wa_qamr with key

prueflos = wa_qamv-prueflos

vorglfnr = wa_qamv-vorglfnr

merknr = wa_qamv-merknr.

wa_final-q_weight = wa_qamr-original_input.

when 'THROW'.

read table i_qamr into wa_qamr with key

prueflos = wa_qamv-prueflos

vorglfnr = wa_qamv-vorglfnr

merknr = wa_qamv-merknr.

wa_final-q_weight = wa_qamr-original_input.

endcase.

wa_final-yards = '0.9144' * wa_final-act_mtrs.

clear : wa_qamv.

endloop.

endif.

append wa_final to it_final.

clear : wa_final,

wa_qamr.

endloop.

endform. " process_data

&----


*& Form field_cat

&----


  • text

----


  • -->P_GS_FCAT text

----


form field_cat using ks_fcat type slis_t_fieldcat_alv.

data : l_fcat type slis_fieldcat_alv.

  • FOR ROLL NO

l_fcat-fieldname = 'COUNT'.

l_fcat-outputlen = '10'.

l_fcat-seltext_l = 'ROLL NO'.

l_fcat-seltext_m = 'ROLL NUM'.

l_fcat-seltext_s = 'ROLL NUMBER'.

append l_fcat to ks_fcat.

clear : l_fcat.

*FOR ART NO

l_fcat-fieldname = 'ARTNO'.

l_fcat-outputlen = '10'.

l_fcat-seltext_l = 'ART NO'.

l_fcat-seltext_m = 'ARTICAL NUM'.

l_fcat-seltext_s = 'ARTICAL NUMBER'.

append l_fcat to ks_fcat.

clear : l_fcat.

*FOR DSN NO

l_fcat-fieldname = 'MATNR'.

l_fcat-outputlen = '10'.

l_fcat-seltext_l = 'DSN NO'.

l_fcat-seltext_m = 'DSN NUM'.

l_fcat-seltext_s = 'DSN NUMBER'.

append l_fcat to ks_fcat.

clear : l_fcat.

*shade No

l_fcat-fieldname = 'ATWRT'.

l_fcat-outputlen = '10'.

l_fcat-seltext_l = 'SHADE NO'.

l_fcat-seltext_m = 'SHADE NUM'.

l_fcat-seltext_s = 'SHADE NUMBER'.

append l_fcat to ks_fcat.

clear : l_fcat.

*BATCH NUMBER

l_fcat-fieldname = 'CHARG'.

l_fcat-outputlen = '10'.

l_fcat-seltext_l = 'BATCH NO'.

l_fcat-seltext_m = 'BATCH NUM'.

l_fcat-seltext_s = 'BATCH NUMBER'.

append l_fcat to ks_fcat.

clear : l_fcat.

*PCS NUMBER

l_fcat-fieldname = 'UECHA'.

l_fcat-outputlen = '10'.

l_fcat-seltext_l = 'PCS NO'.

l_fcat-seltext_m = 'PCS NUM'.

l_fcat-seltext_s = 'PCS NUMBER'.

append l_fcat to ks_fcat.

clear : l_fcat.

*---FOR METERS

l_fcat-fieldname = 'ACT_MTRS'.

l_fcat-outputlen = '25'.

l_fcat-seltext_l = 'MTRS'.

l_fcat-seltext_m = 'METERS'.

l_fcat-seltext_s = 'METERS'.

append l_fcat to ks_fcat.

clear : l_fcat.

*---FOR yards

l_fcat-fieldname = 'YARDS'.

l_fcat-outputlen = '25'.

l_fcat-seltext_l = 'YARDS'.

l_fcat-seltext_m = 'YARDS'.

l_fcat-seltext_s = 'YARDS'.

append l_fcat to ks_fcat.

clear : l_fcat.

*---FOR FLAG

l_fcat-fieldname = 'T_FLAGS'.

l_fcat-outputlen = '25'.

l_fcat-seltext_l = 'FLAG'.

l_fcat-seltext_m = 'FLAG'.

l_fcat-seltext_s = 'FLAG'.

append l_fcat to ks_fcat.

clear : l_fcat.

*---FOR THRO

l_fcat-fieldname = 'THROW'.

l_fcat-outputlen = '25'.

l_fcat-seltext_l = 'THRO'.

l_fcat-seltext_m = 'THRO'.

l_fcat-seltext_s = 'THRO'.

append l_fcat to ks_fcat.

clear : l_fcat.

*--- FOR T_POINTS

l_fcat-fieldname = 'T_POINTS'.

l_fcat-outputlen = '25'.

l_fcat-seltext_l = 'POINT'.

l_fcat-seltext_m = 'POINT'.

l_fcat-seltext_s = 'POINT'.

append l_fcat to ks_fcat.

clear : l_fcat.

*---- FOR Q_WEIGHT GROSS WEIGHT

l_fcat-fieldname = 'Q_WEIGHT'.

l_fcat-outputlen = '25'.

l_fcat-seltext_l = 'NET WT'.

l_fcat-seltext_m = 'NET WT KG'.

l_fcat-seltext_s = 'NET WT KG'.

append l_fcat to ks_fcat.

clear : l_fcat.

endform. " field_cat

&----


*& Form layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form layout .

gs_layout-zebra = c_x.

gs_layout-get_selinfos = c_x.

gs_layout-detail_popup = c_x.

endform. " layout

&----


*& Form list_header

&----


  • text

----


  • -->P_GS_LISTHEADER text

----


form list_header using ks_listheader type slis_t_listheader.

data : p_listheader type slis_listheader.

p_listheader-typ = 'H'.

p_listheader-info = text-h01.

append p_listheader to ks_listheader.

clear : p_listheader.

endform. " list_header

&----


*& Form alv_events

&----


  • text

----


  • -->P_GS_EVENTS text

----


form alv_events using ks_events type slis_t_event.

data : p_events type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = ks_events

  • EXCEPTIONS

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

*-- TOP_OF_PAGE

read table ks_events into p_events with key name = 'TOP_OF_PAGE'.

if sy-subrc is initial.

p_events-form = slis_ev_top_of_page.

modify ks_events from p_events index sy-tabix.

endif.

*-- USER_COMMAND

read table ks_events into p_events with key name = 'USER_COMMAND'.

if sy-subrc is initial.

p_events-form = slis_ev_user_command.

modify ks_events from p_events index sy-tabix.

endif.

endform. " alv_events

&----


*& Form TOP_OF_PAGE

&----


  • text

----


*form top_of_page.

*

*call function 'REUSE_ALV_COMMENTARY_WRITE'

*exporting

*it_list_commentary = gs_listheader

  • I_LOGO =

  • I_END_OF_LIST_GRID =

*.

*

*

*endform. "TOP_OF_PAGE

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_data .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = c_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 = gs_layout

it_fieldcat = gs_fcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'X'

  • IS_VARIANT =

it_events = gs_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_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. " display_data

regards,

raman.