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

Attach a document to shipment

Former Member
0 Likes
2,316

Hi Gurus,

  I have a requirement where I need to attach the smart form from output type to a shipment as an xls. I have created the smart form and managed to convert to .xls using the function module convert_otf. My challenge is attaching it to shipment. I tried to search on the forumns and got to know about function module  SO_OBJECT_INSERT and class  SO_OBJECT_INSERT. But having issues as follows:

1. Not able to find a Object in SWO1 for shipment. The object OIG_BUS001 , OIG_BUS002, and VTTK dont seem to work.

2. I have written a function module as below and trying to execute it. It says success but when I go to vt03n and display the shipment to document is attached to it.

FUNCTION Z_UPDATE_DOC_SHIPMENT.

*"----------------------------------------------------------------------

*"*"Update Function Module:

*"

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(IM_TKNUM) TYPE  VTTK-TKNUM

*"  TABLES

*"      IM_TDLINES STRUCTURE  TLINE

*"----------------------------------------------------------------------

  Datal_key      TYPE swo_typeid ,

         l_type     TYPE swo_objtyp ,

         ls_fol_id   TYPE soodk,

         ls_obj_data TYPE sood1,

         ls_obj_id   TYPE soodk,

         ls_bapiret  TYPE bapiret2,

         l_desc     TYPE so_obj_des .                   " Test pdf documents

  Data: it_objhead  TYPE STANDARD TABLE OF soli,

        it_content  LIKE STANDARD TABLE OF soli.

   CONCATENATE  'CI' im_tknum INTO l_desc.

   l_key = im_tknum.

   l_type = 'VTTK'.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'      " Call Function Module for Change the Table Line Width

     TABLES

       content_in                  = IM_TDLINES

       content_out                 = it_content

     EXCEPTIONS

       err_line_width_src_too_long = 1

       err_line_width_dst_too_long = 2

       err_conv_failed             = 3

       OTHERS                      = 4.

CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'       " Call the Function Module for Converts into Bin

     EXPORTING

       it_contents_bin = it_content[]

     IMPORTING

       et_contents_bin = it_content[].

   CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'         " Call the Function Module to get the Folder Id

     EXPORTING

       region    = 'B'                            "was B

     IMPORTING

       folder_id = ls_fol_id

     EXCEPTIONS

       OTHERS    = 1.

   ls_obj_data-objsns    = 'O'.

   ls_obj_data-objla     = sy-langu.

   ls_obj_data-objdes    = l_desc.

   ls_obj_data-file_ext  = 'XLS'.

   ls_obj_data-objlen    = Lines( it_content ) * 255.

   CALL FUNCTION 'SO_OBJECT_INSERT'

     EXPORTING

       folder_id             = ls_fol_id

       object_type           = 'EXT'

       object_hd_change      = ls_obj_data

     IMPORTING

       object_id             = ls_obj_id

     TABLES

       objhead               = it_objhead

       objcont               = it_content

     EXCEPTIONS

       active_user_not_exist = 35

       folder_not_exist      = 6

       object_type_not_exist = 17

       owner_not_exist       = 22

       parameter_error       = 23

       OTHERS                = 1000.

   Commit Work.

ENDFUNCTION.



Please Help

Hi Gurus,

  I have a requirement where I need to attach the smart form from output type to a shipment as an xls. I have created the smart form and managed to convert to .xls using the function module convert_otf. My challenge is attaching it to shipment. I tried to search on the forumns and got to know about function module  SO_OBJECT_INSERT and class  SO_OBJECT_INSERT. But having issues as follows:

1. Not able to find a Object in SWO1 for shipment. The object OIG_BUS001 , OIG_BUS002, and VTTK dont seem to work.

2. I have written a function module as below and trying to execute it. It says success but when I go to vt03n and display the shipment to document is attached to it.

FUNCTION Z_UPDATE_DOC_SHIPMENT.

*"----------------------------------------------------------------------

*"*"Update Function Module:

*"

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(IM_TKNUM) TYPE  VTTK-TKNUM

*"  TABLES

*"      IM_TDLINES STRUCTURE  TLINE

*"----------------------------------------------------------------------

  Datal_key      TYPE swo_typeid ,

         l_type     TYPE swo_objtyp ,

         ls_fol_id   TYPE soodk,

         ls_obj_data TYPE sood1,

         ls_obj_id   TYPE soodk,

         ls_bapiret  TYPE bapiret2,

         l_desc     TYPE so_obj_des .                   " Test pdf documents

  Data: it_objhead  TYPE STANDARD TABLE OF soli,

        it_content  LIKE STANDARD TABLE OF soli.

   CONCATENATE  'CI' im_tknum INTO l_desc.

   l_key = im_tknum.

   l_type = 'VTTK'.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'      " Call Function Module for Change the Table Line Width

     TABLES

       content_in                  = IM_TDLINES

       content_out                 = it_content

     EXCEPTIONS

       err_line_width_src_too_long = 1

       err_line_width_dst_too_long = 2

       err_conv_failed             = 3

       OTHERS                      = 4.

CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'       " Call the Function Module for Converts into Bin

     EXPORTING

       it_contents_bin = it_content[]

     IMPORTING

       et_contents_bin = it_content[].

   CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'         " Call the Function Module to get the Folder Id

     EXPORTING

       region    = 'B'                            "was B

     IMPORTING

       folder_id = ls_fol_id

     EXCEPTIONS

       OTHERS    = 1.

   ls_obj_data-objsns    = 'O'.

   ls_obj_data-objla     = sy-langu.

   ls_obj_data-objdes    = l_desc.

   ls_obj_data-file_ext  = 'XLS'.

   ls_obj_data-objlen    = Lines( it_content ) * 255.

   CALL FUNCTION 'SO_OBJECT_INSERT'

     EXPORTING

       folder_id             = ls_fol_id

       object_type           = 'EXT'

       object_hd_change      = ls_obj_data

     IMPORTING

       object_id             = ls_obj_id

     TABLES

       objhead               = it_objhead

       objcont               = it_content

     EXCEPTIONS

       active_user_not_exist = 35

       folder_not_exist      = 6

       object_type_not_exist = 17

       owner_not_exist       = 22

       parameter_error       = 23

       OTHERS                = 1000.

   Commit Work.

ENDFUNCTION.



Please Help

3 REPLIES 3
Read only

Former Member
0 Likes
1,371

I got the solution.

Read only

JL23
Active Contributor
1,371

And this solution is now your secret?

You expect answers from others but do not want to share your fresh piece of knowledge with others. Without updating the solution  this discussion it just useless for anybody reading it in future.

Read only

former_member608755
Discoverer
0 Likes
1,371

agree with jurgen lins