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: 

printing the header of a report and checking the join statement...

Former Member
0 Kudos
89

Hi All,

This report of mne is working fine but there are things that i want to include: when i print this report i want it to display heading of which is in the html_top_of_page but it does not print it, i am not familiar with smart forms so i won't be able to use smart forms.If anyone can help me out i will really appreciated and will immediately reward points......please help me guys as the due date is very close...and please check the joins on the select statement, not sure whether i've joined the tables properly!

REPORT Z_ORDER_AUDIT_NEW.

TYPE-POOLS: SLIS.

----


  • LIST OF TABLES

----


Tables: vbak, likp, vbrk, kna1, vbrp, nast.

----


  • DEFINITION OF FIELDS *

----


DATA: itb_fieldcat TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

w_fieldcat TYPE slis_fieldcat_alv.

DATA: w_cnt LIKE sy-tabix.

DATA: lv_layout TYPE slis_layout_alv,

lv_tab_group TYPE slis_t_sp_group_alv,

lv_repid LIKE sy-repid,

lv_events TYPE slis_t_event,

lv_print TYPE slis_print_alv,

lv_user TYPE slis_formname VALUE 'USER_COMMAND'.

----


  • SELECTION SCREEN *

----


SELECT-OPTIONS:

s_lfdat FOR likp-lfdat,

s_imwrk FOR likp-imwrk.

----


  • DEFINITION OF AN INTERNAL TABLE *

----


DATA: Begin of i_ordertab occurs 0,

audat LIKE vbak-audat,

vbeln LIKE vbak-vbeln,

lfdat LIKE likp-lfdat,

erdat LIKE likp-erdat,

vbeln1 LIKE likp-vbeln,

vbeln2 LIKE vbrk-vbeln,

erdat1 LIKE vbrk-erdat,

kunrg LIKE vbrk-kunrg,

name1 LIKE kna1-name1,

regio LIKE vbrk-regio,

inco1 LIKE vbrk-inco1,

vrkme LIKE vbrp-vrkme,

ntgew LIKE vbrp-ntgew,

gewei LIKE vbrp-gewei,

volum LIKE vbrp-volum,

voleh LIKE vbrp-voleh,

netwr LIKE vbrk-netwr,

End of i_ordertab.

----


  • READ THE DATA *

----


SELECT vbakaudat vbakvbeln likplfdat likperdat likpvbeln vbrkvbeln

vbrkerdat vbrkkunrg kna1name1 vbrkregio vbrkinco1 vbrpvrkme

vbrpntgew vbrpgewei vbrpvolum vbrpvoleh vbrk~netwr

FROM likp join kna1 on likpkunnr EQ kna1kunnr

join vbrk on kna1kunnr EQ vbrkkunrg

join vbrp on vbrkvbeln EQ vbrpvbeln

join vbak on kna1kunnr EQ vbakkunnr

INTO i_ordertab

WHERE likp~lfdat IN s_lfdat

AND likp~imwrk IN s_imwrk.

APPEND i_ordertab.

ENDSELECT.

----


  • PERFORM STATEMENTS *

----


PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM build_event.

PERFORM build_print.

PERFORM display_alv_report.

&----


FORM build_fieldcatalog.

&----


w_cnt = 1.

itb_fieldcat-fieldname = 'AUDAT'.

itb_fieldcat-seltext_m = 'Document date'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

itb_fieldcat-key = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'VBELN'.

itb_fieldcat-seltext_m = 'S/O number'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'LFDAT'.

itb_fieldcat-seltext_m = 'Deliv. date'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'ERDAT'.

itb_fieldcat-seltext_m = 'Del. Crt Date'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'VBELN1'.

itb_fieldcat-seltext_m = 'Delivery No.'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'VBELN2'.

itb_fieldcat-seltext_m = 'Invoice No.'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'ERDAT1'.

itb_fieldcat-seltext_m = 'Invoice Date'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'KUNRG'.

itb_fieldcat-seltext_m = 'Payer'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'NAME1'.

itb_fieldcat-seltext_m = 'Payer-Description'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'REGIO'.

itb_fieldcat-seltext_m = 'Region'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'INCO1'.

itb_fieldcat-seltext_m = 'Incoterms'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'VRKME'.

itb_fieldcat-seltext_m = 'Billed Quantity'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'NTGEW'.

itb_fieldcat-seltext_m = 'Net weight'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'GEWEI'.

itb_fieldcat-seltext_m = 'Weight Unit'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'VOLUM'.

itb_fieldcat-seltext_m = 'Volume'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'VOLEH'.

itb_fieldcat-seltext_m = 'VOLUME UNIT'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

w_cnt = w_cnt + 1.

itb_fieldcat-fieldname = 'NETWR'.

itb_fieldcat-seltext_m = 'Net Value'.

itb_fieldcat-col_pos = w_cnt.

itb_fieldcat-emphasize = 'X'.

itb_fieldcat-ref_tabname = 'VBRK' .

itb_fieldcat-ref_fieldname = 'NETWR' .

itb_fieldcat-do_sum = 'X' .

APPEND itb_fieldcat TO itb_fieldcat.

CLEAR itb_fieldcat.

ENDFORM.

&----


FORM build_layout.

&----


lv_layout-no_input = 'X'.

lv_layout-colwidth_optimize = 'X'.

lv_layout-totals_text = 'Totals'(201).

lv_layout-detail_popup = 'X'.

ENDFORM.

&----


FORM build_event.

&----


DATA i_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = lv_events[].

READ TABLE lv_events WITH KEY name = slis_ev_user_command

INTO i_event.

if sy-subrc = 0.

MOVE lv_user TO i_event-form.

APPEND i_event TO lv_events.

endif.

ENDFORM.

----


FORM build_print.

----


lv_print-reserve_lines = '2'.

lv_print-no_coverpage = 'X'.

ENDFORM.

&----


*& FUNCTION ALV DISPLAY

&----


FORM display_alv_report.

lv_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = lv_repid

I_CALLBACK_USER_COMMAND = slis_ev_user_command

I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE' " see FORM

I_CALLBACK_HTML_END_OF_LIST = 'END_OF_LIST_HTML' "see FORM

IS_LAYOUT = lv_layout

IT_FIELDCAT = itb_fieldcat[]

IT_SPECIAL_GROUPS = lv_tab_group

I_SAVE = 'X'

IT_EVENTS = lv_events

IS_PRINT = lv_print

TABLES

t_outtab = i_ordertab

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

ENDFORM.

&----


*& Form html_top_of_page

&----


FORM html_top_of_page USING document TYPE REF TO cl_dd_document.

DATA: text TYPE sdydo_text_element.

CALL METHOD document->add_gap

EXPORTING

width = 100.

text = 'Cadbury: Daily Audit of Orders'.

CALL METHOD document->add_text

EXPORTING

text = text

sap_style = 'HEADING'.

CALL METHOD document->new_line.

CALL METHOD document->new_line.

CALL METHOD document->new_line.

text = 'User Name : '.

CALL METHOD document->add_text

EXPORTING

text = text

sap_emphasis = 'Strong'.

CALL METHOD document->add_gap

EXPORTING

width = 6.

text = sy-uname.

CALL METHOD document->add_text

EXPORTING

text = text

sap_style = 'Key'.

CALL METHOD document->add_gap

EXPORTING

width = 50.

text = 'Date : '.

CALL METHOD document->add_text

EXPORTING

text = text

sap_emphasis = 'Strong'.

CALL METHOD document->add_gap

EXPORTING

width = 6.

text = sy-datum.

CALL METHOD document->add_text

EXPORTING

text = text

sap_style = 'Key'.

CALL METHOD document->add_gap

EXPORTING

width = 50.

text = 'Time : '.

CALL METHOD document->add_text

EXPORTING

text = text

sap_emphasis = 'Strong'.

CALL METHOD document->add_gap

EXPORTING

width = 6.

text = sy-uzeit.

CALL METHOD document->add_text

EXPORTING

text = text

sap_style = 'Key'.

ENDFORM.

----


FORM end_of_list_html USING end TYPE REF TO cl_dd_document.

----


DATA: ls_text TYPE sdydo_text_element,

l_grid TYPE REF TO cl_gui_alv_grid,

f(14) TYPE c VALUE 'SET_ROW_HEIGHT',

w_lines type i,

w_lines1(9) type n.

DESCRIBE TABLE i_ordertab LINES w_lines.

w_lines1 = w_lines.

concatenate: 'TOTAL NUMBER OF RECORDS SELECTED: ' w_lines1 INTO ls_text

SEPARATED BY space.

  • adds test (via variable)

CALL METHOD end->add_text

EXPORTING

text = ls_text

sap_emphasis = 'strong'.

  • adds new line (start new line)

CALL METHOD end->new_line.

*set height of this section

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = l_grid.

CALL METHOD l_grid->parent->parent->(f)

EXPORTING

id = 3

height = 14.

ENDFORM. "end_of_list_html.

--


END OF THE REPORT--

1 REPLY 1

Former Member
0 Kudos
61

Hi

1. first remove the ENDSELECT..use INTO table itab or INTO CORRESPONDING fields, Since you are joining the more tables this will take lot of time.

2. You are just using two fields from LIKP as selection screen fields to fetch the so much data.

see the table linkings apartfrom KUNNR between the tables

LIKP-VBELN = LIPS-VBELN

LIPS-VGBEL = VBAK-VBELN and LIPS-VGPOS = VBAP-POSNR

and

VBRP-AUBEL = VBAK-VBELN and VBRP-AUPOS = VBAP-POSNR and

VBRP-VGBEL = LIKP-VBELN and VBRP-VGPOS = LIPS-POSNR

use the above links and code again.

<b>Reward points for useful Answers</b>

Regards

Anji