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

Coding examples for calling VF31

Former Member
0 Likes
2,465

Hi to all,

I would like to use transaction VF31 to reprint invoices in a program. I would like to loop at my internal table and calling VF31 for every record and for two different Output types. I would like to use command CALL TRANSACTION and avoid using a recording from SHDB to populate the different screen fields. I am struggling in populating the parameters.

I have read a bunch of old threads referring to VF31 but I cannot find one with some coding examples. Can anyone send me some coding blocks or refer me to any old threads?

Thank you very much.

BR,

Sylvain

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,395

Hi Sylvain,

Have you tried to run this report (SD70AV3A) in background mode? I've tried it and it prints all the selected invoices, and there's no list to be shown and there's also no need to click the checkboxes for the invoices you'd like to print.

So some coding could be:


DATA: name LIKE tbtcjob-jobname.
DATA: number LIKE tbtcjob-jobcount.
DATA: print_parameters TYPE pri_params.

name = 'INVOICE_PRINTING'.

RANGES: range FOR nase-kschl.

CLEAR: range.
REFRESH: range.
range-sign = 'I'.
range-option = 'EQ'.
range-low = 'first_output_type'.
CLEAR: range-high.
APPEND range.

range-sign = 'I'.
range-option = 'EQ'.
range-low = 'second_output_type'.
CLEAR: range-high.
APPEND range.

CALL FUNCTION 'JOB_OPEN'
  EXPORTING
    jobname          = name
  IMPORTING
    jobcount         = number
  EXCEPTIONS
    cant_create_job  = 1
    invalid_job_data = 2
    jobname_missing  = 3
    OTHERS           = 4.
IF sy-subrc = 0.
  SUBMIT sd70av3a WITH rg_kschl IN range
                  TO SAP-SPOOL
                  SPOOL PARAMETERS print_parameters
                  WITHOUT SPOOL DYNPRO
                  VIA JOB name NUMBER number
                  AND RETURN.
  IF sy-subrc = 0.
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = number
        jobname              = name
        strtimmed            = 'X'
      EXCEPTIONS
        cant_start_immediate = 1
        invalid_startdate    = 2
        jobname_missing      = 3
        job_close_failed     = 4
        job_nosteps          = 5
        job_notex            = 6
        lock_failed          = 7
        OTHERS               = 8.
    IF sy-subrc <> 0.
      ...
    ENDIF.
  ENDIF.
ENDIF.

I hope this helps. Kind regards,

Alvaro

2 REPLIES 2
Read only

Former Member
0 Likes
1,396

Hi Sylvain,

Have you tried to run this report (SD70AV3A) in background mode? I've tried it and it prints all the selected invoices, and there's no list to be shown and there's also no need to click the checkboxes for the invoices you'd like to print.

So some coding could be:


DATA: name LIKE tbtcjob-jobname.
DATA: number LIKE tbtcjob-jobcount.
DATA: print_parameters TYPE pri_params.

name = 'INVOICE_PRINTING'.

RANGES: range FOR nase-kschl.

CLEAR: range.
REFRESH: range.
range-sign = 'I'.
range-option = 'EQ'.
range-low = 'first_output_type'.
CLEAR: range-high.
APPEND range.

range-sign = 'I'.
range-option = 'EQ'.
range-low = 'second_output_type'.
CLEAR: range-high.
APPEND range.

CALL FUNCTION 'JOB_OPEN'
  EXPORTING
    jobname          = name
  IMPORTING
    jobcount         = number
  EXCEPTIONS
    cant_create_job  = 1
    invalid_job_data = 2
    jobname_missing  = 3
    OTHERS           = 4.
IF sy-subrc = 0.
  SUBMIT sd70av3a WITH rg_kschl IN range
                  TO SAP-SPOOL
                  SPOOL PARAMETERS print_parameters
                  WITHOUT SPOOL DYNPRO
                  VIA JOB name NUMBER number
                  AND RETURN.
  IF sy-subrc = 0.
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = number
        jobname              = name
        strtimmed            = 'X'
      EXCEPTIONS
        cant_start_immediate = 1
        invalid_startdate    = 2
        jobname_missing      = 3
        job_close_failed     = 4
        job_nosteps          = 5
        job_notex            = 6
        lock_failed          = 7
        OTHERS               = 8.
    IF sy-subrc <> 0.
      ...
    ENDIF.
  ENDIF.
ENDIF.

I hope this helps. Kind regards,

Alvaro

Read only

0 Likes
1,395

Hi Alvaro,

Thank you for your answer. It was really helpful.

Sylvain