cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform to Spool

Former Member
0 Kudos

Hi experts,

i hope you can help me. I want to print a smartform to a normal spool in the System (no pdf). Than I want to combine two spools (one abaplist Spool and the Smartform Spool) into a new spool in the system. Thats it. I know this sounds pretty easy, but i've searched for hours and nothing found, so i hope someone can give me a hint.

best regards

Martin Hofman

Accepted Solutions (1)

Accepted Solutions (1)

satyajit_mohapatra
Active Contributor
0 Kudos

It's really an unique requirement. As ABAP LIST spools and FORM spools are different, it's not possible to achive it through RSPO* FMs alone. But, we can readily convert the form output to OTF. If the spool also can be converted to OTF, then we can merge both the OTF data and print the final OTF content to generate the spool.

Please check the code below. I'm saving the ABAP List spool to a standard text and creating the OTF for it. Then, I'm merging this OTF data with the Form OTF and generating the final spool. Give it a try and let me know in case of any issues.

satyajit_mohapatra
Active Contributor
0 Kudos


TYPES: BEGIN OF t_list,
        line TYPE char255,
       END OF t_list.

DATA: wf_fm      TYPE rs38l_fnam,
      int_oinfo  TYPE ssfcrescl,
      int_otf    TYPE tsfotf,
      int_otf1   TYPE tsfotf,
      wa_otf1    LIKE LINE OF  int_otf1,
      wa_cparam  TYPE ssfctrlop,
      wa_output  TYPE ssfcompop,
      wa_options TYPE itcpo,
      wf_spool   TYPE itcpp-tdspoolid,
      int_list   TYPE TABLE OF t_list,
      int_lines  TYPE TABLE OF tline,
      wa_list    TYPE t_list,
      wa_lines   TYPE tline,
      wa_header  TYPE thead,
      wf_index   TYPE sy-tabix.

wa_output-tddest    = 'LP01'.
wa_cparam-no_dialog = 'X'.
wa_cparam-preview   = space.
wa_cparam-getotf    = 'X'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname = 'YSM_TEST' "My Smartform
  IMPORTING
    fm_name  = wf_fm.

CALL FUNCTION wf_fm
  EXPORTING
    control_parameters = wa_cparam
    output_options     = wa_output
  IMPORTING
    job_output_info    = int_oinfo.

* Smartform OTF
int_otf = int_oinfo-otfdata[].

CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
  EXPORTING
    rqident = 26751 "ABAP List Spool No
  TABLES
    buffer  = int_list.

LOOP AT int_list INTO wa_list.
  wa_lines-tdformat = '*'.
  wa_lines-tdline   = wa_list-line.
  APPEND wa_lines TO int_lines.
ENDLOOP.

CALL FUNCTION 'CREATE_TEXT'
  EXPORTING
    fid       = 'ST'
    flanguage = 'E'
    fname     = 'YSM_DYN'
    fobject   = 'TEXT'
  TABLES
    flines    = int_lines.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
    id       = 'ST'
    language = 'E'
    name     = 'YSM_DYN'
    object   = 'TEXT'
  IMPORTING
    header   = wa_header
  TABLES
    lines    = int_lines.

wa_options-tddest    = 'LP01'.
wa_options-tdgetotf    = 'X'.

CALL FUNCTION 'PRINT_TEXT'
  EXPORTING
    dialog  = ' '
    header  = wa_header
    OPTIONS = wa_options
  TABLES
    lines   = int_lines
    otfdata = int_otf1.

DELETE int_otf WHERE tdprintcom = '//'.

READ TABLE int_otf1 INTO wa_otf1 WITH KEY tdprintcom = 'EP'
                                       TRANSPORTING NO FIELDS.

IF sy-subrc EQ 0.

wf_index = sy-tabix + 1.

INSERT lines of int_otf INTO int_otf1 INDEX wf_index.

wa_options-tddest    = 'LP01'.

CALL FUNCTION 'PRINT_OTF'
  EXPORTING
    printoptions = wa_options
  IMPORTING
    spoolid      = wf_spool
  TABLES
    otf          = int_otf1.

WRITE:/ 'Check Spool', wf_spool.

ENDIF.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try Function Module SO_SPOOL_READ.

Cheers,

Dep