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 lists in ABAP without using the standard button

Former Member
0 Kudos

Dear community,

i've got a little problem and I can't fix it on my own.

Some user in our company gave me the instruction to extend an existing SAP Programmm with some defined functionalities.

They want to implement an new button for printing in the gui status and when someone uses the buttons they want to count down a number and print the generated list of the report.

I created also the new button in the gui status with a own functioncode and in the report i implemented an own AT USER-Command event:

*&----


**& Event

*&----


AT USER-Command.

CASE sy-ucomm.

WHEN 'PRVR'.

CALL FUNCTION 'PRINT_REPORT'

EXPORTING

report = sy-cprog

EXCEPTIONS

OTHERS = 99.

When I push my own print button th reports jumps in the At-user-command event.

The window for chosing the print properties will appear immediatly and I cn start printing.

But only the spool-order will only appear when I leave the list-view with the button "back", "exit", or "cancel".

Has anyone an idea why the output appears only when I go back to the selection screen?

Can anybody tell me how to create an printing function to print out the list of an abap-report? I don't wnt to use the normal print-button!

Many thanks in advance.

Michael

8 REPLIES 8

former_member583013
Active Contributor
0 Kudos

Try this...


        NEW-PAGE PRINT ON
        DESTINATION P_DEST2
        IMMEDIATELY ' '
        KEEP IN SPOOL ' '
        LINE-SIZE 100
        NEW LIST IDENTIFICATION 'X'
        NO DIALOG.

* You report

        NEW-PAGE PRINT OFF.

That way...You report would be printed as soon as you press the button -;)

P.S: If you wanted to keep it in Spool...KEEP IN SPOOL 'X'.

Greetings,

Blag.

0 Kudos

Dear alvaro, many thanks for your answer.

I sorry that I can't understand your soltion. I know this syntax only from printing forms. I just want to print the list of an report.

Perhaps you can me give me example with my coding to make me understand you?

Many thanks in advance.

Michael

0 Kudos

It's not only for forms -:)


        NEW-PAGE PRINT ON
        DESTINATION P_DEST2
        IMMEDIATELY ' '
        KEEP IN SPOOL ' '
        LINE-SIZE 100
        NEW LIST IDENTIFICATION 'X'
        NO DIALOG.
 
        WRITE:/ SY-DATUM.
        WRITE:/ SY-UNAME.

        SKIP 1.

        LOOP AT T_TABLE.
        WRITE:/ TABLE-FIELD1, TABLE-FIELD2.
        ENDLOOP.

        NEW-PAGE PRINT OFF.

Just need to put the Printing logic after you start writing your report -;)

Greetings,

Blag.

0 Kudos

Hi alvaro, many thanks again for your quick answer.

But I can't use your solution, because I don't want to print the list direct on creation. I want to print the ready list which is shown on the display by clicking an own button, just like the SAP functionality on the print button.

Do you understand?

Out of these reasons I tried to use the function 'PRINT_REPORT'. But this doesn't work correctly.

Has anybody an idea how to solve my problem?

Michael

0 Kudos

Ok Michael...Now I see what you want to do -:) I have never used <b>PRINT_REPORT</b> FM....So I don't think I can provide any more help.... -:( Sorry....

Greetings,

Blag.

Former Member
0 Kudos

Hi Michael,

i have tried it with this code:

REPORT ZGRO_TEST1.

*

TABLES: MARA.

*

START-OF-SELECTION.

*

SELECT * FROM MARA UP TO 100 ROWS.

WRITE: MARA-MATNR.

ENDSELECT.

*

AT USER-COMMAND.

*

<b> SY-LSIND = 0.</b>*

CASE SY-UCOMM.

WHEN 'PRPV'.

CALL FUNCTION 'PRINT_REPORT'

EXPORTING

  • NO_DIALOG = 'X'

<b> REPORT = SY-REPID.</b> ENDCASE.

Perhaps you have to set SY-LSIND = 0.

Hope it helps.

regards, Dieter

0 Kudos

Dear Dieter,

I'm very gradefull about your answer.

But I don't understand the coding. What does the value SY-LSIND mean and why have I got to set it to 1?

I hope you can explain me.

Many thanks and bye...

Michael

Former Member
0 Kudos

Hi Michael,

sy-lsind is the list-id. If you set it to 0 or 1 it jumps (when using BACK)

to the first output-list.

Here a short demo-code to understand it.

Make severeal time doubleclick in the outputline and

look at the changing output.

try it with:

  • sy-lsind = 1

and

sy-lsind = 1.

*

REPORT ZGRO_TEST1.

*

data: dc type i value 1.

START-OF-SELECTION.

*

WRITE: / 'List:', dc, 'SY-LSIND:', SY-LSIND.

HIDE: SY-LSIND.

*

AT LINE-SELECTION.

dc = dc + 1.

  • sy-lsind = 1.

WRITE: / 'List:', dc, 'SY-LSIND:', SY-LSIND.

HIDE: SY-LSIND.

*

Hope it helps.

Regards, Dieter