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 docs using control parameters

Former Member
0 Kudos
340

Hello,

I had a problem in printing multiple document in one spool request and the issue was solved, Now in the select option if i give "From"  "To" numbers( Eg 50000002 to 50000005)  the printing is done and if i give only one document number the print does not trigger.

Please find the code

w_cnt2 = sy-tabix.
  case w_cnt2.
when 1.
control_parameters-no_open   = space .
control_parameters-no_close  = 'X' .
when w_cnt .
control_parameters-no_open   = 'X' .
control_parameters-no_close  = space .
when others.
control_parameters-no_open   = 'X' .
control_parameters-no_close  = 'X' .
endcase.

Kindly help.

Regards,

Sam.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
313

Hi

I hope you use Select Option in your selection screen .

Case 1#   If you pass "From and To"   then your documents printing successfully.

           

Case 2#  If you pass only From  then your document not printing .

            Pass both From and To as same document number  and  check document is printed

            successfully or Not .

Example :

Regard's

Smruti

14 REPLIES 14

JJosh
Active Participant
0 Kudos
313

Hi,

If there is only one doc no in the selection screen, append the same low value to TO (HIGH) field also in the program.

Regards,

Josh

nabheetscn
Active Contributor
0 Kudos
313

Hi Samuel

I would suggest you to debug your program may be the control is not going to the place where you are printing

Nabheet

0 Kudos
313

Hi Nabheet,

        When iam able to print more than one doc, i dont understand why only one doc does not get printed.

Do you want me to post the entire code snippet.

Regards,

Sam.

0 Kudos
313

Hi Samuel

It looks like you have some sort of counter or stuff which you are using in your code. Can you please paste only the loop endloop stuff inside which printing is happening

Nabheet

0 Kudos
313

Hi Nabheet,

Please refere the below code.

LOOP at it_main INTO wa_main.
w_cnt2 = sy-tabix.
  case w_cnt2.
when 1.
control_parameters-no_open   = space .
control_parameters-no_close  = 'X' .
when w_cnt .
control_parameters-no_open   = 'X' .
control_parameters-no_close  = space .
when others.
control_parameters-no_open   = 'X' .
control_parameters-no_close  = 'X' .
endcase.


  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
     EXPORTING
       formname               = 'ZVOUCHER1'
  IMPORTING
    fm_name                   = fname
  EXCEPTIONS
    NO_FORM                  = 1
    NO_FUNCTION_MODULE       = 2
    OTHERS                   = 3.

   IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.

CALL FUNCTION fname"'/1BCDWB/SF00000143'
   EXPORTING
    CONTROL_PARAMETERS          = control_parameters
     doc_no                     = wa_main-belnr
     co_code                    = wa_main-bukrs
     period                     = wa_main-gjahr

  EXCEPTIONS
    FORMATTING_ERROR           = 1
    INTERNAL_ERROR             = 2
    SEND_ERROR                 = 3
    USER_CANCELED              = 4
    OTHERS                     = 5
           .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

ENDLOOP.


Regards,

Sam.

0 Kudos
313

Hi Sam

Its not working becuase the system is expectiong for the last call

NO_OPEN = 'X'.
NO_CLOSE = SPACE
.

But since your loop has only one line  only first case statement is processed not the abvoe mentioned.

Do one thing just before the loop do a

Describe table it_main lines lv_lines.

LOOP at it_main INTO wa_main.
w_cnt2 = sy-tabix.
  case w_cnt2.
when 1.

if lv_lines ne 1.
control_parameters-no_open   = space .
control_parameters-no_close  = 'X' .

else.

control_parameters-no_open   = 'X' .

control_parameters-no_close  = space .

endif.
when w_cnt .
control_parameters-no_open   = 'X' .
control_parameters-no_close  = space .
when others.
control_parameters-no_open   = 'X' .
control_parameters-no_close  = 'X' .
endcase.


  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
     EXPORTING
       formname               = 'ZVOUCHER1'
  IMPORTING
    fm_name                   = fname
  EXCEPTIONS
    NO_FORM                  = 1
    NO_FUNCTION_MODULE       = 2
    OTHERS                   = 3.

   IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.

CALL FUNCTION fname"'/1BCDWB/SF00000143'
   EXPORTING
    CONTROL_PARAMETERS          = control_parameters
     doc_no                     = wa_main-belnr
     co_code                    = wa_main-bukrs
     period                     = wa_main-gjahr

  EXCEPTIONS
    FORMATTING_ERROR           = 1
    INTERNAL_ERROR             = 2
    SEND_ERROR                 = 3
    USER_CANCELED              = 4
    OTHERS                     = 5
           .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

ENDLOOP.

0 Kudos
313

Nabheet,

       Describe statement is already there and i tried the case statement as per your coding but it dint work.

Regards,

Sam.

Former Member
0 Kudos
313

Hi,

It's seems to be problem of sy-tabix. where you are getting the count. Please check the field.

w_cnt2 = sy-tabix.


Thanks,

Kiran

Former Member
0 Kudos
314

Hi

I hope you use Select Option in your selection screen .

Case 1#   If you pass "From and To"   then your documents printing successfully.

           

Case 2#  If you pass only From  then your document not printing .

            Pass both From and To as same document number  and  check document is printed

            successfully or Not .

Example :

Regard's

Smruti

0 Kudos
313

Hi Smruti,

   I tried as per your method and it din't work.

Regards,

sam.

0 Kudos
313

Did you try as recommended in previous post

0 Kudos
313

Yes i did and nothing had changed.

0 Kudos
313

Change as below

if lv_lines ne 1.
control_parameters-no_open   = space .
control_parameters-no_close  = 'X' .

else.

control_parameters-no_open   = space .

control_parameters-no_close  = space .

endif.

0 Kudos
313

Hi Nabheet,

Excellent!

Thank you so much. The issue has been solved.

Thanks all for all your support.

Regards,

Sam.