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

hi code doubt

Former Member
0 Likes
381

&----


*& Report ZTR0001

*&

&----


*&

*&

&----


report ztr0001

no standard page heading

line-size 255.

tables: zsd0005, vbrk, zsd0004.

data: it_zsd0004 like zsd0004 occurs 0 with header line,

it_zsd0005 like zsd0005 occurs 0 with header line,

i_data like zsd0005 occurs 0 with header line.

data: begin of i_data1 occurs 0,

sup_doc_name like zsd0005-sup_doc_name,

chrg_weight like zsd0004-chrg_weight,

lr_no like zsd0005-lr_no,

end of i_data1.

data: begin of i_data2 occurs 0,

sup_doc_name like zsd0005-sup_doc_name,

chrg_weight like zsd0004-chrg_weight,

exact_amt like zsd0004-chrg_weight,

lr_no like zsd0005-lr_no,

vbeln like zsd0004-vbeln, "SMIT

fkdat like zsd0004-fkdat,

lr_date like zsd0004-lr_date,

werks like zsd0004-werks,

name1 like t001w-name1,

lifnr like zsd0004-lifnr,

name2 like lfa1-name1,

tran_bill_amt like zsd0005-tran_bill_amt,

tran_bill_no like zsd0005-tran_bill_no,

tran_bill_date like zsd0005-tran_bill_date,

end of i_data2.

data: i_data3 like i_data2 occurs 0 with header line.

data: v_sup_doc_name like zsd0005-sup_doc_name,

w_name1 like t001w-name1,

w_name2 like lfa1-name1.

      • start of Alv data declaration**

type-pools : slis.

data :alv_fieldcat type slis_t_fieldcat_alv,

alv_fieldcat_line like line of alv_fieldcat,

alv_sort type slis_t_sortinfo_alv,

alv_sort_line like line of alv_sort,

alv_layout type slis_layout_alv,

g_repid like sy-repid,

alv_status_set type slis_formname value 'ALV_STATUS_SET',

alv_user_comm type slis_formname value 'ALV_USER_COMM',

grid_title type lvc_title,

alv_fieldcat_acty type slis_t_fieldcat_alv,

g_save,

gs_variant like disvariant,

g_exit_caused_by_caller type c,

gs_exit_caused_by_user type slis_exit_by_user,

r_ucomm like sy-ucomm,

rs_selfield type slis_selfield.

data: alv_fieldcat_line_acty like line of alv_fieldcat_acty,

alv_layout_acty type slis_layout_alv,

gt_list_top_of_page type slis_t_listheader,

gt_events type slis_t_event,

message type string.

constants:

gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.

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

selection-screen : begin of block b1 with frame title main.

*PARAMETERS : P_LRNO LIKE ZSD0005-LR_NO OBLIGATORY.

select-options: so_dat for zsd0004-fkdat obligatory.

parameters : p_werks like zsd0004-werks,

p_lifnr like zsd0004-lifnr.

selection-screen end of block b1.

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

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

initialization.

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

start-of-selection.

perform get_data.

if i_data2[] is initial.

message 'No records to display.' type 'I'.

clear: so_dat-low, so_dat-high.

*PERFORM DISPLAY.

else.

*MESSAGE 'No records to display.' TYPE 'I'.

perform display.

endif.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

select * from zsd0004 into table it_zsd0004

where fkdat in so_dat and

werks = p_werks and

lifnr = p_lifnr.

check sy-subrc eq 0.

select * from zsd0005 into table it_zsd0005

for all entries in it_zsd0004

where lr_no = it_zsd0004-lr_no.

sort it_zsd0005 by sup_doc_name.

i_data[] = it_zsd0005[].

*LOOP AT IT_ZSD0005.

*DELETE ADJACENT DUPLICATES FROM IT_ZSD0005. "COMPARING SUP_DOC_NAME.

loop at it_zsd0005.

if v_sup_doc_name is initial.

v_sup_doc_name = it_zsd0005-sup_doc_name.

else.

if v_sup_doc_name = it_zsd0005-sup_doc_name.

delete it_zsd0005.

else.

v_sup_doc_name = it_zsd0005-sup_doc_name.

endif.

endif.

endloop.

loop at it_zsd0005.

*AT NEW IT_ZSD0005-SUP_DOC_NAME.

loop at i_data where sup_doc_name = it_zsd0005-sup_doc_name.

i_data1-sup_doc_name = it_zsd0005-sup_doc_name.

read table it_zsd0004 with key lr_no = i_data-lr_no.

if sy-subrc eq 0.

i_data1-lr_no = i_data-lr_no.

i_data1-chrg_weight = it_zsd0004-chrg_weight.

endif.

append i_data1.

endloop.

endloop.

sort i_data1 by sup_doc_name chrg_weight.

*COLLECT I_DATA1 INTO I_DATA2.

loop at i_data1.

i_data2-sup_doc_name = i_data1-sup_doc_name.

i_data2-chrg_weight = i_data1-chrg_weight.

i_data2-lr_no = i_data1-lr_no.

*V_WEIGHT = V_WEIGHT + I_DATA1-CHRG_WEIGHT.

append i_data2.

clear: i_data1, i_data2.

endloop.

sort i_data2 by sup_doc_name.

loop at i_data2.

i_data3-sup_doc_name = i_data2-sup_doc_name.

i_data3-chrg_weight = i_data2-chrg_weight.

collect i_data3.

endloop.

loop at i_data2.

clear it_zsd0005.

clear i_data3.

read table it_zsd0005 with key sup_doc_name = i_data2-sup_doc_name.

read table i_data3 with key sup_doc_name = i_data2-sup_doc_name.

if i_data3-chrg_weight ne 0.

i_data2-exact_amt = i_data2-chrg_weight * ( it_zsd0005-tran_bill_amt / i_data3-chrg_weight ).

endif.

  • >>> BEGIN OF MODIFICATION SMIT

read table it_zsd0004 with key lr_no = i_data2-lr_no.

i_data2-vbeln = it_zsd0004-vbeln.

i_data2-fkdat = it_zsd0004-fkdat.

i_data2-lr_date = it_zsd0004-lr_date.

i_data2-werks = it_zsd0004-werks.

select single name1 from t001w into w_name1

where werks = it_zsd0004-werks.

if sy-subrc eq 0.

i_data2-name1 = w_name1.

endif.

i_data2-lifnr = it_zsd0004-lifnr.

select single name1 from lfa1 into w_name2

where lifnr = it_zsd0004-lifnr.

if sy-subrc eq 0.

i_data2-name2 = w_name2.

endif.

read table i_data with key lr_no = i_data2-lr_no.

i_data2-tran_bill_amt = i_data-tran_bill_amt.

i_data2-tran_bill_no = i_data-tran_bill_no.

i_data2-tran_bill_date = i_data-tran_bill_date.

  • <<< END OF MODIFICATION SMIT

modify i_data2 transporting exact_amt vbeln fkdat lr_date werks name1 lifnr name2 tran_bill_amt tran_bill_no tran_bill_date.

*CLEAR I_DATA2.

endloop.

endform. " GET_DATA

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display .

perform build_field_catelog .

perform eventtab_build changing gt_events.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = 'ZTR0001'

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'ALV_USER_COMM'

is_layout = alv_layout

it_fieldcat = alv_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'X'

i_save = 'A'

is_variant = gs_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

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = i_data2

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.

perform alv_user_comm using r_ucomm

rs_selfield.

if sy-subrc = 0.

if g_exit_caused_by_caller = 'X'.

else.

if gs_exit_caused_by_user-back = 'X'. " F3

else.

if gs_exit_caused_by_user-exit = 'X'. " F15

else.

if gs_exit_caused_by_user-cancel = 'X'. " F12

else.

endif.

endif.

endif.

endif.

else.

endif.

endform. " DISPLAY

&----


*& Form build_field_catelog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_field_catelog .

clear: alv_fieldcat.

refresh: alv_fieldcat.

  • DOC NUMBER

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Billing Doc No'.

alv_fieldcat_line-fieldname = 'VBELN'.

alv_fieldcat_line-outputlen = '10'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • BILLING DOC DATE

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Billing Doc Date'.

alv_fieldcat_line-fieldname = 'FKDAT'.

alv_fieldcat_line-outputlen = '8'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • SUP DOC NO

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Sup Doc No'.

alv_fieldcat_line-fieldname = 'SUP_DOC_NAME'.

alv_fieldcat_line-outputlen = '10'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • LR NO

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'LR No'.

alv_fieldcat_line-fieldname = 'LR_NO'.

alv_fieldcat_line-outputlen = '10'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • LR DATE

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'LR Date'.

alv_fieldcat_line-fieldname = 'LR_DATE'.

alv_fieldcat_line-outputlen = '8'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • LR AMOUNT

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'LR Amount'.

alv_fieldcat_line-fieldname = 'EXACT_AMT'.

alv_fieldcat_line-outputlen = '15'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • PLANT CODE

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Plant'.

alv_fieldcat_line-fieldname = 'WERKS'.

alv_fieldcat_line-outputlen = '10'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • PLANT NAME

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Plant Name'.

alv_fieldcat_line-fieldname = 'NAME1'.

alv_fieldcat_line-outputlen = '10'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • TRANSPORTER CODE

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Transporter'.

alv_fieldcat_line-fieldname = 'LIFNR'.

alv_fieldcat_line-outputlen = '10'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • TRANSPORTER NAME

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Transporter Name'.

alv_fieldcat_line-fieldname = 'NAME2'.

alv_fieldcat_line-outputlen = '20'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • TRANSPORTER INVOICE AMOUNT

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Transporter Inv Amt'.

alv_fieldcat_line-fieldname = 'TRAN_BILL_AMT'.

alv_fieldcat_line-outputlen = '13'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • TRANSPORTER INVOICE NO

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Transporter Inv No'.

alv_fieldcat_line-fieldname = 'TRAN_BILL_NO'.

alv_fieldcat_line-outputlen = '10'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

  • TRANSPORTER INVOICE DATE

alv_fieldcat_line-tabname = 'I_DATA2'.

alv_fieldcat_line-seltext_l = 'Transporter Inv Date'.

alv_fieldcat_line-fieldname = 'TRAN_BILL_DATE'.

alv_fieldcat_line-outputlen = '8'.

append alv_fieldcat_line to alv_fieldcat.

clear alv_fieldcat_line.

endform. " build_field_catelog

&----


*& Form eventtab_build

&----


  • text

----


  • <--P_GT_EVENTS text

----


form eventtab_build changing lt_events type slis_t_event.

field-symbols: <lt_events> like line of lt_events.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = lt_events

exceptions

list_type_wrong = 1

others = 2.

  • Define TOP_OF_PAGE event

read table lt_events with key name = slis_ev_top_of_page

assigning <lt_events>.

if sy-subrc eq 0.

move gc_formname_top_of_page to <lt_events>-form.

endif.

endform. " eventtab_build

&----


*& Form alv_user_comm

&----


  • text

----


  • -->P_R_UCOMM text

  • -->P_RS_SELFIELD text

----


form alv_user_comm using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

*Determine the main component beign viewed

read table i_data2 index rs_selfield-tabindex.

case r_ucomm.

when '&IC1'. " single / double click

endcase.

endform. " alv_user_comm

&----


*& Form TOP_OF_PAGE

&----


form top_of_page.

refresh gt_list_top_of_page.

clear gt_list_top_of_page.

perform comment_build using gt_list_top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = gt_list_top_of_page

i_logo = 'ZYDUS_LOGO'.

endform. "top_of_page

&----


*& Form COMMENT_BUILD

&----


  • Build comments at top of page

----


form comment_build changing gt_top_of_page type slis_t_listheader.

data: gs_line type slis_listheader.

clear gs_line.

gs_line-typ = 'H'.

gs_line-info = 'Service tax on GTA'.

append gs_line to gt_top_of_page.

clear gs_line.

gs_line-typ = 'S'.

gs_line-key = 'Report ID:'.

gs_line-info = sy-repid.

append gs_line to gt_top_of_page.

clear gs_line.

gs_line-typ = 'S'.

gs_line-key = 'User:'.

gs_line-info = sy-uname.

append gs_line to gt_top_of_page.

clear gs_line.

gs_line-typ = 'S'.

gs_line-key = 'Date:'.

write sy-datum to gs_line-info mm/dd/yyyy.

append gs_line to gt_top_of_page.

clear gs_line.

gs_line-typ = 'S'.

gs_line-key = 'Time:'.

write sy-uzeit to gs_line-info using edit mask '__:__:__'.

append gs_line to gt_top_of_page.

clear gs_line.

gs_line-typ = 'S'.

gs_line-key = ''.

write ' '.

append gs_line to gt_top_of_page.

  • Output data from selection screen

endform. "comment_build

1 REPLY 1
Read only

Former Member
0 Likes
334

ijij