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

Printing using ALV_GRID

Former Member
0 Likes
624

Hi,

I'm facing printing problem using alv_grid. I have successfully created reports using alv grid as the layout. The example of the illustration of the alv grid layout as follow

Company Code Amount

3001 2000

3001 1000

3001 500

3002 5000

3002 10000

The problem is, the client require every new company code, the printing will be in new page.... 3001 in one page and 3002 in one page.....

Any clue or advice how am i going to control this printing ?

Hi,

Map following code to your program.

in the IT_SORT parameter of list display

there should be entry like this .

it_sort-fieldname = 'BUKRS'. "Filedname for company code
it_Sort-group = '*'.
append it_sort.

And alv grid will display each company code data in new page.

Hope that helps.

Regards

Kapadia

***Assigning points is the way to say thanks in SDN.***

5 REPLIES 5
Read only

Former Member
0 Likes
595

Instead of GRID, u can use Hierarchial list display.

at every new Company code, display a separate list.

Hope this may solve ur issue.

Regards,

Sujatha.

Read only

Former Member
0 Likes
595

Jonathan,

http://www.geocities.com/mpioud/Abap_programs.html.

OR

REPORT z_demo_alv_sort_2.

----


  • This program lists orders (VBAK) with sort for 'Sales organization' *

  • (VKORG), 'sold-to-party' (KUNNR) and 'Document number' (VBELN) *

----


----


TYPES :

BEGIN OF ty_vbak,

vkorg TYPE vbak-vkorg, " Sales organization

kunnr TYPE vbak-kunnr, " Sold-to party

vbeln TYPE vbak-vbeln, " Sales document

audat TYPE vbak-audat, " Document date

END OF ty_vbak.

DATA :

vbak TYPE vbak,

gt_vbak TYPE TABLE OF ty_vbak.

SELECT-OPTIONS :

s_vkorg FOR vbak-vkorg, " Sales organization

s_kunnr FOR vbak-kunnr, " Sold-to party

s_vbeln FOR vbak-vbeln. " Sales document

SELECTION-SCREEN SKIP.

SELECTION-SCREEN : BEGIN OF LINE, COMMENT 1(35) v_1 FOR FIELD p_page.

PARAMETERS p_page RADIOBUTTON GROUP optn.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN : BEGIN OF LINE, COMMENT 1(35) v_2 FOR FIELD p_ligne.

PARAMETERS p_ligne RADIOBUTTON GROUP optn.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN : BEGIN OF LINE, COMMENT 1(35) v_3 FOR FIELD p_nthng.

PARAMETERS p_nthng RADIOBUTTON GROUP optn.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN :

SKIP, BEGIN OF LINE,COMMENT 5(27) v_4 FOR FIELD p_max.

PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.

SELECTION-SCREEN END OF LINE.

----


INITIALIZATION.

v_1 = 'New page at ''Sales Org.'' break'.

v_2 = 'Underline at ''Sales Org.'' break'.

v_3 = 'Nothing'.

v_4 = 'Maximum of records to read'.

----


START-OF-SELECTION.

PERFORM f_read_data.

PERFORM f_display_data.

----


  • Form f_read_data

----


FORM f_read_data.

SELECT vkorg kunnr vbeln audat

UP TO p_max ROWS

INTO TABLE gt_vbak

FROM vbak

WHERE kunnr IN s_kunnr

AND vbeln IN s_vbeln

AND vkorg IN s_vkorg.

ENDFORM. " F_READ_DATA

----


  • Form f_display_data

----


FORM f_display_data.

TYPE-POOLS: slis. " ALV Global types

  • Macro definition

DEFINE m_fieldcat.

add 1 to ls_fieldcat-col_pos.

ls_fieldcat-fieldname = &1.

ls_fieldcat-ref_tabname = 'VBAK'.

append ls_fieldcat to lt_fieldcat.

END-OF-DEFINITION.

DEFINE m_sort.

add 1 to ls_sort-spos.

ls_sort-fieldname = &1.

ls_sort-up = 'X'.

ls_sort-group = &2.

append ls_sort to lt_sort.

END-OF-DEFINITION.

DATA:

ls_fieldcat TYPE slis_fieldcat_alv,

lt_fieldcat TYPE slis_t_fieldcat_alv,

lt_sort TYPE slis_t_sortinfo_alv,

ls_sort TYPE slis_sortinfo_alv,

ls_layout TYPE slis_layout_alv,

ls_grid_settings TYPE lvc_s_glay.

*

ls_grid_settings-top_p_only = 'X'.

m_fieldcat 'VKORG'.

m_fieldcat 'KUNNR'.

m_fieldcat 'VBELN'.

m_fieldcat 'AUDAT'.

IF p_page = 'X'.

m_sort 'VKORG' '*'. " Sort by vkorg + Page break

ELSEIF p_ligne = 'X'.

m_sort 'VKORG' 'UL'. " Sort by vkorg + Underline

ELSE.

m_sort 'VKORG' ' '. " Sort by vkorg

ENDIF.

m_sort 'KUNNR' ' '. " Sort by kunnr

m_sort 'VBELN' ' '. " Sort by vbeln

ls_layout-colwidth_optimize = 'X'.

ls_layout-zebra = 'X'.

ls_layout-cell_merge = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_top_of_page = 'TOP_OF_PAGE'

is_layout = ls_layout

i_grid_settings = ls_grid_settings

it_fieldcat = lt_fieldcat

it_sort = lt_sort

TABLES

t_outtab = gt_vbak.

ENDFORM. " F_DISPLAY_DATA

----


  • FORM top_of_page *

----


FORM top_of_page. "#EC CALLED

ULINE.

WRITE : sy-title(65) CENTERED, 'Page :' , sy-pagno .

ULINE.

ENDFORM.

                                • END OF PROGRAM Z_DEMO_ALV_SORT_2 *********************

Pls. reward if useful

Read only

Former Member
0 Likes
595

hi

Instead of GRID, u can use Hierarchial list display.

at every new Company code, display a separate list.

Hope this may solve ur issue.

**Please reward suitable points***

With Regards

Navin Khedikar

Read only

Former Member
0 Likes
595

Hi,

Map following code to your program.

in the IT_SORT parameter of list display

there should be entry like this .

it_sort-fieldname = 'BUKRS'. "Filedname for company code
it_Sort-group = '*'.
append it_sort.

And alv grid will display each company code data in new page.

Hope that helps.

Regards

Kapadia

***Assigning points is the way to say thanks in SDN.***

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
595

Hi

Instead of ALV Grid you can achieve this thru Classical Report.

Using at new burks

Display the data in seperate page.

Regards,

kumar