cancel
Showing results for 
Search instead for 
Did you mean: 

Adobe form to MIME

shabir_ismail
Participant
0 Kudos

Hello experts,

I am trying to convert a spool (got when generation an Adobe form) to a MIME.

However when reading the file, it says that the file is corrupted.

Can you please help me where did i go wrong please?

DATA: lv_spool LIKE tsp01-rqident.

DATA: lt_pdf TYPE TABLE OF tline.

DATA: ls_pdf LIKE LINE OF lt_pdf.

DATA: lv_url TYPE char255.

DATA: lv_buffer TYPE string.

DATA: lv_content  TYPE xstring.

   DATA: o_mr_api            TYPE REF TO  if_mr_api,

                       is_folder             TYPE              boole_d,

                       lv_current           TYPE               string,

                       lv_url1                 TYPE               string,

                       l_loio                 TYPE               skwf_io.

FIELD-SYMBOLS <fs_x> TYPE x.

   lv_spool = 781691.

* Convert the spool request to PDF format.

   CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

     EXPORTING

       src_spoolid              = lv_spool

     TABLES

       pdf                      = lt_pdf

     EXCEPTIONS

       err_no_abap_spooljob     = 1

       err_no_spooljob          = 2

       err_no_permission        = 3

       err_conv_not_possible    = 4

       err_bad_destdevice       = 5

       user_cancelled           = 6

       err_spoolerror           = 7

       err_temseerror           = 8

       err_btcjob_open_failed   = 9

       err_btcjob_submit_failed = 10

       err_btcjob_close_failed  = 11

       OTHERS                   = 12.

   LOOP AT lt_pdf INTO ls_pdf.

    TRANSLATE ls_pdf USING '~'.

     CONCATENATE lv_current ls_pdf INTO  lv_current.

   ENDLOOP.

      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

         EXPORTING

           text   lv_current

         IMPORTING

           buffer = lv_content.

   IF o_mr_api IS INITIAL.

     o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).

   ENDIF.

   lv_url = '/sap/bc/bsp/sap/ztest_msi/test.pdf'.

     o_mr_api->put(

              EXPORTING

                i_url                         = lv_url

                i_content                     = lv_content

                i_suppress_package_dialog     = 'X'

                i_new_loio                    = l_loio

                i_suppress_dialogs            = 'X'

              EXCEPTIONS

                parameter_missing             = 1

                error_occured                 = 2

                cancelled                     = 3

                permission_failure            = 4

                data_inconsistency            = 5

                new_loio_already_exists       = 6

                is_folder                     = 7

                OTHERS                        = 8 ).

Accepted Solutions (0)

Answers (1)

Answers (1)

shabir_ismail
Participant
0 Kudos

hello experts,

Have someone found the bug in the program ?

Regards

Shabir Ismail

shabir_ismail
Participant
0 Kudos

solved.

Former Member
0 Kudos

Hi Shabir,

Could you please tell the community how you resolved it so that other people with the same problem won't have to ask again?

Thx!!

shabir_ismail
Participant
0 Kudos

I havent use the spool finally.

Instead i used the adobe form.

" Get the name of the form

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name    
= 'XXX'
IMPORTING
e_funcname
= l_name.



CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams
= ls_outputparams
EXCEPTIONS
cancel         
= 1
usage_error    
= 2
system_error   
= 3
internal_error 
= 4
OTHERS          = 5.

“ Call the form without viewing or printing it

CALL FUNCTION l_name
EXPORTING
test       
= 'zzzz'
IMPORTING
/1BCDWB/FORMOUTPUT      
= output
EXCEPTIONS
USAGE_ERROR             
= 1
SYSTEM_ERROR            
= 2
INTERNAL_ERROR          
= 3
OTHERS                   = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


CALL FUNCTION 'FP_JOB_CLOSE'
EXCEPTIONS
usage_error   
= 1
system_error  
= 2
internal_error
= 3
OTHERS         = 4.



" convert the raw string to xstring
lv_content
= output-pdf.

IF o_mr_api IS INITIAL.
o_mr_api
= cl_mime_repository_api=>if_mr_api~get_api( ).
ENDIF.


“ The url for creating the mime object


lv_url
= '/sap/bc/zzzz'.


“ Creation du fichier mime


o_mr_api->put(
EXPORTING
i_url                        
= lv_url
i_content                    
= lv_content
i_suppress_package_dialog    
= 'X'
i_new_loio                   
= l_loio
i_suppress_dialogs           
= 'X'
EXCEPTIONS
parameter_missing            
= 1
error_occured                
= 2
cancelled                    
= 3
permission_failure           
= 4
data_inconsistency           
= 5
new_loio_already_exists      
= 6
is_folder                    
= 7
OTHERS                        = 8 ).

Former Member
0 Kudos

Nice!

Ca pourra toujours aider et je pense même que je vais l'utiliser d'ici la fin de mon projet!

The primary language of most spaces is English. Non-English content should be posted in the appropriate language-specific space (see the Site Index)

-edited by moderator Gabor Cseh

shabir_ismail
Participant
0 Kudos

c'est sure.

Bonne chance. Tu travaille sur quoi ?

The primary language of most spaces is English. Non-English content should be posted in the appropriate language-specific space (see the Site Index)

-edited by moderator Gabor Cseh

Former Member
0 Kudos

Hi Shabir,

For one of my client i have to display pdf form in SAP UI. But when i am calling my pdf form if and  passing below parameters. It's showing print preview . I want only raw string without display.

data:  fp_outputparams TYPE sfpoutputparams,

                 gi_pdf_output TYPE FPFORMOUTPUT.

fp_outputparams-nodialog = 'X'.

fp_outputparams-preview = space.

* Sets the output parameters and opens the spool job

   CALL FUNCTION 'FP_JOB_OPEN'                   "& Form Processing: Call Form

     CHANGING

       ie_outputparams = fp_outputparams

     EXCEPTIONS

       cancel          = 1

       usage_error     = 2

       system_error    = 3

       internal_error  = 4

       OTHERS          = 5.

   IF sy-subrc <> 0.

*            <error handling>

   ENDIF.

*&---- Get the name of the generated function module

   CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'           "& Form Processing Generation

     EXPORTING

       i_name     = 'ZHR_COMP_PROFILE'

     IMPORTING

       e_funcname = fm_name.

   IF sy-subrc <> 0.

*  <error handling>

   ENDIF.

   fp_docparams-langu   = 'E'.

   fp_docparams-country = 'US'.

*  fp_docparams-FILLABLE = 'F'.

*&--- Call the generated function module

   CALL FUNCTION fm_name

     EXPORTING

*      /1bcdwb/docparams  = fp_docparams

       pwb_data           = gi_final

     IMPORTING

       /1bcdwb/formoutput = gi_pdf_output

     EXCEPTIONS

       usage_error        = 1

       system_error       = 2

       internal_error     = 3.

   IF sy-subrc <> 0.

*  <error handling>

   ENDIF.

Kindly let me know which parameter i am missing. I tried with   parameter

fp_outputparams-getpdf = 'X'. But its not working.

shabir_ismail
Participant
0 Kudos

Try the following:

  w_ssfctrlop-no_dialog = abap_true.

  w_ssfctrlop-device    = space.

  w_ssfctrlop-getotf    = abap_true.

  w_ssfcompop-tddest    = 'LOCL'.

  w_ssfcompop-tdimmed   = abap_true.

Former Member
0 Kudos

Thanks Shabir for replying. But I have adobe form and  i want only pdfstring without display for sap UI.   w_ssfctrlop-getotf    = abap_true ,  this option is not available . This option only available when we convert smartform to PDF. For me only below options are available. And its giving me  sy-subrc 1( i.e. usage error)

fp_outputparams-nodialog = abap_true.

  fp_outputparams-getpdf = abap_true.

  fp_outputparams-device = space.

  fp_outputparams-dest = 'LOCL'.

  fp_outputparams-reqimm = abap_true.


* Sets the output parameters and opens the spool job

  CALL FUNCTION 'FP_JOB_OPEN'                   "& Form Processing: Call Form

    CHANGING

      ie_outputparams = fp_outputparams

    EXCEPTIONS

      cancel          = 1

      usage_error     = 2

      system_error    = 3

      internal_error  = 4

      OTHERS          = 5.

  IF sy-subrc <> 0.

*            <error handling>

  ENDIF.

*&---- Get the name of the generated function module

  CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'           "& Form Processing Generation

    EXPORTING

      i_name     = 'ZHR_COMP_PROFILE'

    IMPORTING

      e_funcname = fm_name.

  IF sy-subrc <> 0.

*  <error handling>

  ENDIF.



  fp_docparams-langu   = 'E'.

  fp_docparams-country = 'US'.

*&--- Call the generated function module

  CALL FUNCTION fm_name

    EXPORTING

     /1bcdwb/docparams  = fp_docparams

      pwb_data           = gi_final

    IMPORTING

      /1bcdwb/formoutput = gi_pdf_output

    EXCEPTIONS

      usage_error        = 1

      system_error       = 2

      internal_error     = 3.

 

shabir_ismail
Participant
0 Kudos

It has been a long time i haven't use Adobe form.

No sure how to do it.

Try generating the spool and convert it to PDF. May be that will work

Here is the code to generate the spool.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

     EXPORTING

       immediately            = space

       no_dialog              = abap_true

       user                     = sy-uname

     IMPORTING

       out_parameters         = w_pri_params

     EXCEPTIONS

       archive_info_not_found = 1

       invalid_print_params   = 2

       invalid_archive_params = 3

       OTHERS                 = 4.

   IF sy-subrc <> 0.

   ENDIF.


NEW-PAGE PRINT ON NO DIALOG PARAMETERS w_pri_params.