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 report directly from printer

Former Member
0 Likes
1,812

Hi,

I need a small information.if any one of our guys can give me some info that would be great.

I am writing a ABAP report now. lets say when we write 'hello world' in code and F8 program o/p will show 'hello world' right. I need to print this through user default printer automatically...might be pop-up for confirmation would help.

Thanks in advance...

Raj

Hi,

I need a small information.if any one of our guys can give me some info that would be great.

I am writing a ABAP report now. lets say when we write 'hello world' in code and F8 program o/p will show 'hello world' right. I need to print this through user default printer automatically...might be pop-up for confirmation would help.

Thanks in advance...

Raj

12 REPLIES 12
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,692

You might want to check out the PRINT-CONTROL statement. Do F1 help on PRINT-CONTROL.

Regards,

Rich Heilman

Read only

0 Likes
1,692

Thanks Rich., I will try to work it out.

Read only

Former Member
0 Likes
1,692

Hi Raj,

Also explore the use of "SUBMIT rep ... TO SAP-SPOOL." statement.

Look at following link for example -

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/submit_t.htm

Cheers,

Sanjeev

Read only

0 Likes
1,692

Hi Sanjay,

Its nice information I will check that code monday.

Read only

0 Likes
1,692

Hi,

I am developing a function module..with in the function module i am submitting the report ZREPORT with matnr.

In ZREPORT i do some validations and formated the list and needs to be printrd.

what i did is in ZREPORT it self i wrote the following code. Submiting the same report in the report. Finally my control has to FM.But screen gets blank.Please suggest me if i am in wrong direction.

In FM:submit ztestraj with p_matnr = '1234'

and return.

in Report ZREPORT

submit zreport TO SAP-SPOOL

DESTINATION 'LOCL'

COPIES 1

LIST NAME 'NEWLIST'

LIST DATASET 'TESTLIST'

COVER TEXT 'Test variables'

LIST AUTHORITY 'BASIS'

IMMEDIATELY 'X'

KEEP IN SPOOL 'X'

NEW LIST IDENTIFICATION 'X'

DATASET EXPIRATION '8'

LINE-COUNT 80

LINE-SIZE 120

LAYOUT 'X_80_120'

SAP COVER PAGE 'X'

COVER PAGE 'X'

RECEIVER 'SAP*'

DEPARTMENT 'DEP.'

WITHOUT SPOOL DYNPRO and return.

Read only

0 Likes
1,692

Please post the complete code of the ZREPORT.

Regards,

Rich Heilman

Read only

0 Likes
1,692

Hi Rich,

Calling program is

REPORT ZTESTRAJ1 .

parameters:p_date like sy-datum.

DATA: SELTAB TYPE TABLE OF RSPARAMS,

SELTAB_WA LIKE LINE OF SELTAB.

start-of-selection.

CLEAR SELTAB_WA.

MOVE: 'p_date' TO SELTAB_WA-SELNAME,

'P' TO SELTAB_WA-KIND, " PARAMETER

sy-datum TO SELTAB_WA-LOW.

APPEND SELTAB_WA TO SELTAB.

CLEAR SELTAB_WA.

MOVE: 'p_matnr' TO SELTAB_WA-SELNAME,

'P' TO SELTAB_WA-KIND, " PARAMETER

'1233344' TO SELTAB_WA-LOW.

APPEND SELTAB_WA TO SELTAB.

SUBMIT Ztestraj with p_date eq sy-datum

with p_uname eq sy-uname

with p_matnr eq '122333' and return.

if sy-subrc = 0.

write 'Printed'.

endif.

Here is the program Ztestraj

parameters:

p_matnr like mara-matnr,

p_date like sy-datum,

p_uname like sy-uname.

data: l_matnr like mcha-matnr.

start-of-selection.

l_matnr = p_matnr.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

INPUT = l_matnr

IMPORTING

OUTPUT = l_matnr

  • EXCEPTIONS

  • LENGTH_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.

WRITE: L_MATNR.

DATA: PARAMS LIKE PRI_PARAMS,

DAYS(1) TYPE N VALUE 2,

COUNT(3) TYPE N VALUE 1,

VALID TYPE C.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING DESTINATION = 'LOCL'

COPIES = COUNT

LIST_NAME = 'ZTESTRAJ'

LIST_TEXT = 'SUBMITTO SAP-SPOOL'

IMMEDIATELY = 'X'

RELEASE = 'X'

NEW_LIST_ID = 'X'

EXPIRATION = DAYS

LINE_SIZE = 80

LINE_COUNT = 120

LAYOUT = 'X_44_120'

  • SAP_COVER_PAGE = 'X'

COVER_PAGE = 'X'

  • RECEIVER = 'SAP*'

  • DEPARTMENT = 'System'

NO_DIALOG = 'X'

IMPORTING OUT_PARAMETERS = PARAMS

VALID = VALID.

IF VALID <> SPACE.

SUBMIT ztestraj TO SAP-SPOOL

SPOOL PARAMETERS PARAMS

WITHOUT SPOOL DYNPRO and return.

if sy-subrc = 0.

endif.

ENDIF.

Read only

0 Likes
1,692

You are submitting the same program inside of ZTESTRAJ, but this time you are not sending any parameters, this is why you are not getting your output.

Regards,

RIch Heilman

Read only

0 Likes
1,692

You must pass your values thru to the next call....




    submit  zrich_0003 to sap-spool
    spool parameters params
    without spool dynpro
    with P_matnr = p_matnr
    with p_date = p_date
    with p_uname = p_uname
                and return.

But hang on........ when doing this I'm in a loop and I'm getting an error saying that maximum sessions reached.

I'll get back./

Regards,

Rich Heilman

Read only

0 Likes
1,692

To solve your problem quickly, I would suggest not calling the program inside itself, call another program instead.

Regards,

Rich Heilman

Read only

0 Likes
1,692

Here is a very crude solution for calling the same program in a program, it works but it is not very pretty.

I have changed your program name to mine.



report zrich_0003 .

parameters:
p_matnr like mara-matnr,
p_date like sy-datum,
p_uname like sy-uname,
<b>p_trigr type c default space.</b>
data: l_matnr like mcha-matnr.

start-of-selection.

<b>  if p_trigr = 'X'.</b>

    l_matnr = p_matnr.

    call function 'CONVERSION_EXIT_MATN1_INPUT'
    exporting
    input = l_matnr
    importing
    output = l_matnr
* EXCEPTIONS
* LENGTH_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.

    write: l_matnr.

<b>  else.</b>

    data: params like pri_params,
    days(1) type n value 2,
    count(3) type n value 1,
    valid type c.

    call function 'GET_PRINT_PARAMETERS'
    exporting destination = 'LOCL'
    copies = count
    list_name = 'ZRICH_0003'
    list_text = 'SUBMITTO SAP-SPOOL'
    immediately = 'X'
    release = 'X'
    new_list_id = 'X'
    expiration = days
    line_size = 80
    line_count = 120
    layout = 'X_44_120'
* SAP_COVER_PAGE = 'X'
    cover_page = 'X'
* RECEIVER = 'SAP*'
* DEPARTMENT = 'System'
    no_dialog = 'X'
    importing out_parameters = params
    valid = valid.

    if valid <> space.
      submit  zrich_0003 to sap-spool
      spool parameters params
      without spool dynpro
      with p_matnr = p_matnr
      with p_date = p_date
      with p_uname = p_uname
      with p_trigr  = 'X'
                  and return.

      if sy-subrc = 0.

      endif.
    endif.

<b>  endif.</b>


please remember to award points accordingly. Thanks.

Regards,

Rich Heilman

Read only

0 Likes
1,692

Thanks Rich,

Its still not printing but I am notgetting error.I will try in different ways using your info.

we are attaching FM to screen push button in PI Sheet.

I am calling report from a function module.Within that X report i am calling other report Y.In Y report i am writing this submit-to-spool.Y willhave output list needs to be printed.Finally control has to comeback to the FM.

I am just curious the way i am in is right or Wr?

Thanks