terça-feira, 14 de fevereiro de 2023

Workflow - Erro formatação HTML na exibição SBWP

 - Para exibição de HTML no container da SBWP por mais que o HTML funcione 100% no ambiente tipo chrome, edge ou qualquer outra ferramenta para exibição no SAP especificamente na exibição de conteúdo as vezes aparece algumas tags fora de posição ou aparece a tag mesmo, etc..

Para resolver esse problema fiquei procurando até achar um cara que fala de uma nota da SAP q desconhecia até então falando justamente da do  HTML em editor sapscript.

2472157 - Work item description with HTML table in expression is not displayed correctly

Resumindo a nota a estrutura que deve ser usado para montar o HTML deve ser a RSWEBPUB_T_W3HTML que é a mesma estrutura do editor sapscript

Na primeira linha do sapscript no container do workflow deve ser colocado o texto MAIL_HTML_ONLY e depois a tabela que tem o HTML.

Ficaria dessa forma.

==== Eu alterei o TLINE_T  pela RSWEBPUB_T_W3HTML que é mais apropriado






-- OUTRO FATOR IMPORTANTE - No inbox no FIORI não aceita classes com script, na SBWP aparece certo mas no MY INBOX aparece desformatado, tem q colocar os estilos direto na TAG


EXEMPLO HTMLPARA UMA TABELA
LOOP AT lt_doc REFERENCE INTO DATA(lr_doc).


AT FIRST.

APPEND '<html>' TO rt_html.

APPEND '<style>' TO rt_html.

APPEND 'table, th, td{ text-align: left; font-family: "Helvetica"; }' TO rt_html.

APPEND '</style>' TO rt_html.

APPEND '<body>' TO rt_html.

APPEND '<h2>Liberação de Pagamento para Fornecedor</h2> <p>' TO rt_html.

APPEND |<table>| TO rt_html.

APPEND |<tr>| TO rt_html.

APPEND |<th style="width:200px; text-align:left;">Fornecedor:</th>| TO rt_html.

APPEND |<td style="width:500px; text-align:left;">{ lr_doc->supplier }-{ lr_doc->supplierfullname }</td>| TO rt_html.

APPEND |</tr>| TO rt_html.

APPEND |<tr>| TO rt_html.

APPEND |<th style="width:200px; text-align:left;">Data do Lançamento :</th>| TO rt_html.

APPEND |<td style="width:500px; text-align:left;">{ lr_doc->postingdate DATE = ENVIRONMENT }</td>| TO rt_html.

APPEND |</tr>| TO rt_html.

APPEND |<tr>| TO rt_html.

APPEND |<th style=<th style="width:200px; text-align:left;">Data do Vencimento :</th>| TO rt_html.

APPEND |<td style="width:500px; text-align:left;">{ lr_doc->netduedate DATE = ENVIRONMENT }</td>| TO rt_html.

APPEND |</tr>| TO rt_html.

APPEND |<tr>| TO rt_html.

APPEND |<th style="width:200px; text-align:left;">Texto Cabeçalho :</th>| TO rt_html.

APPEND |<td style="width:500px; text-align:left;">{ lr_doc->documentitemtext }</td>| TO rt_html.

APPEND |</tr>| TO rt_html.

APPEND |<tr>| TO rt_html.

APPEND |<th style="width:200px; text-align:left;">Documento criado por :</th>| TO rt_html.

APPEND |<td style="width:500px; text-align:left;">{ lr_doc->accountingdoccreatedbyuser }-{ lv_username }</td>| TO rt_html.

APPEND |</tr>| TO rt_html.

APPEND |<tr>| TO rt_html.

APPEND |</table>| TO rt_html.


APPEND '</p><p/>' TO rt_html.

APPEND '<table>' TO rt_html.

APPEND |<th style="width:80px; text-align:left; border:1px solid ;">Item</th>| TO rt_html.

APPEND |<th style="width:200px; text-align:center; border:1px solid black;">Valor do item</th>| TO rt_html.

APPEND |<th style="width:70px; text-align:left; border:1px solid black;">Moeda</th>| TO rt_html.

APPEND |<th style="width:150px; text-align:left; border:1px solid black;">Centro de Lucro</th>| TO rt_html.

APPEND |<th style="width:500px; text-align:left; border:1px solid black;">Atribuição</th>| TO rt_html.


APPEND '</tr>' TO rt_html.

ENDAT.


APPEND '<tr>' TO rt_html.

APPEND |<th style="width:80px; text-align:left; border:1px solid ;">{ lr_doc->accountingdocumentitem }</td>| TO rt_html.

APPEND |<th style="width:200px; text-align:right; border:1px solid black;">{ abs( lr_doc->amountincompanycodecurrency ) NUMBER = ENVIRONMENT }</td>| TO rt_html.

APPEND |<th style="width:70px; text-align:left; border:1px solid black;">{ lr_doc->companycodecurrency }</td>| TO rt_html.

APPEND |<th style="width:150px; text-align:left; border:1px solid black;">{ lr_doc->profitcenter }</td>| TO rt_html.

APPEND |<th style="width:500px; text-align:left; border:1px solid black;">{ lr_doc->assignmentreference }</td>| TO rt_html.


APPEND '</tr>' TO rt_html.


ENDLOOP.


APPEND '</table>' TO rt_html.

APPEND '</body>' TO rt_html.

APPEND '</html>' TO rt_html.




Transações WORKFLOW


SWU3 - Configuração de jobs automáticos

SWIA - Para eliminar processos de workflow parados na caixa de entrada 


Transação SMLG - Utilizei essa transação para configurar um erro que dava na conexão do servidor do workflow.

Ao testar a conexão dava um erro que não acha o grupo SPACE, nessa transação SMLG o grupo para o servidor estava em branco, eu preenchi com o SPACE e deu certo 


SWU_OBUFmanual buffer refreshSWPCcontinue WF after a system crash
SWI6show all WF instances, work item IDs by BOR/CL name & Object Key (optional)SWI5work item per work center, job, organizational unit, position, user
SWIAwork item administration (WI)SWI2_DIAGerror diagnosis
SWWLdelete work itemSWI2_DEADdeadline monitor
SWWL_TOPLEVELdelete a parent workflow with all of its child work itemsSWI2_DURAprocess duration
SWUDWF diagnosisSWI2_ADM1find orphaned work item
SWELSevent traceSM12lock, unlock the object
SWELdisplay event traceSARAarchiving

 

Workflow Development

SWDDWF builderSWNADMINnotification management
PFTCtemplate, task management (WS, TS)SM37view scheduled and processed jobs
PFTC_DISassigning possible agentSBWPWF inbox
PFACrule creation, editing, testingSWU0simulate the event linkage
SWO1business object builder (BOR)SWEQADMevent queue, preventing RFC-problem
SWUStest, execute WFSWB_CONDall start conditions
SWEINSTall terminating events linkageSWU9WF trace for the session
SWUI_VERIFYWF verificationSWI1selection report for work item
SOSTSAPconnect transmission requestSWPAcustomizing WF runtime system
SWNCONFIGnotification configurationPPOMorganization & staffing
SWEQBROWSERevent waiting in the event queuePPOMEorganizational management, structure & staff assignment, user mapping
SM52view tRFCSWI2_FREQopened task statistic

 

ABAP Development

SE24classesSE11data types, domains, tables
SE37function modules, functionsSE09list of change requests per SAP user
SE38programsSE03change requests management
ST22runtime error logs, dumpsSTMSchange requests transferring

quinta-feira, 15 de dezembro de 2022

Gravando conteúdo de arquivo em tabelas RAWSTRING


Fonte da informação: https://www.fareez.info/blog/how-to-store-files-in-database-in-abap/





 Gravando.

report  zupload.

parameters:
  p_fname type string lower case.

data:
      gs_store_file type zfar_store_file,
      gt_content type standard table of tdline,
      len type i,
      xstr_content type xstring.

start-of-selection.

  "Upload the file to Internal Table
  call function 'GUI_UPLOAD'
    exporting
      filename                = p_fname
      filetype                = 'BIN'
    importing
      filelength              = len
    tables
      data_tab                = gt_content
    exceptions
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      others                  = 17.

  if sy-subrc <> 0.
    message 'Unable to upload file' type 'E'.
  endif.

  "Convert binary itab to xstring
  call function 'SCMS_BINARY_TO_XSTRING'
    exporting
      input_length       = len
*     FIRST_LINE         = 0
*     LAST_LINE          = 0
   importing
     buffer             = xstr_content
    tables
      binary_tab         = gt_content
   exceptions
     failed             = 1
     others             = 2
            .
  if sy-subrc <> 0.
    message 'Unable to convert binary to xstring' type 'E'.
  endif.

  clear gs_store_file.

  gs_store_file-filename = p_fname.
  gs_store_file-file_content = xstr_content.

  "Insert file into table
  insert zfar_store_file from gs_store_file.

  if sy-subrc is initial.
    message 'Successfully uploaded' type 'S'.
  else.
    message 'Failed to upload' type 'E'.
  endif.

Lendo.

report  zdownload.

parameters:
  p_fname type zfar_store_file-filename lower case,
  p_path type string lower case.


data:
      gs_store_file type zfar_store_file,
      xstr_content type xstring,
      gt_content type standard table of tdline,
      len type i,
      str_fname type string.

start-of-selection.

  select single * from zfar_store_file
    into gs_store_file
    where filename = p_fname.

  xstr_content  = gs_store_file-file_content.

  "Convert xstring/rawstring to binary itab
  call function 'SCMS_XSTRING_TO_BINARY'
    exporting
      buffer        = xstr_content
    importing
      output_length = len
    tables
      binary_tab    = gt_content.
  .

  if sy-subrc <> 0.
    message 'Unable to convert xstring to binary'
      type 'E'.
  endif.

  str_fname = p_fname.

  call function 'GUI_DOWNLOAD'
    exporting
      bin_filesize            = len
      filename                = p_path
      filetype                = 'BIN'
    tables
      data_tab                = gt_content
    exceptions
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      others                  = 22.
  if sy-subrc <> 0.
    message 'Unable to download file from SAP'
      type 'E'.
  endif.





quarta-feira, 26 de outubro de 2022

Salvando arquivos utilizando o GOS - Business document

Utilizado para salvar um anexo dentro de uma integração PI/PO.

Criei um programa teste baseado nesse link

https://sapintegrationhub.com/abap/attach-any-file-sap-business-document-gos/

O programa basicamente seleciona um arquivo qualquer no PC e grava no formato GOS, no caso da integração é so pular alguns passos, já que o anexo em si já vem em formato binário X64.

Incluí nesse programa a rotina de gravar e de importar o arquivo do GOS.

Arquivos gravados podem ser consultados na tabela SOOD somente dados de informação 

Imaginei que teria que criar um objeto(BO) na transação SWO1 mas não é necessário, fiz um teste criando no objeto VBRK mesmo para ver. no meu caso vou usar o objeto VBAK vc pode consultar na tabela TOBJB

**** INCLUDE ZSZKF01 **

*&---------------------------------------------------------------------*
*& Include          ZSZKF01
*&---------------------------------------------------------------------*
*&amp;---------------------------------------------------------------------*
*&amp; Include          ZATTACH_FILE_FORMS
*&amp;---------------------------------------------------------------------*
*&amp;---------------------------------------------------------------------*
*&amp; Form OPEN_FILE_DIALOG
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; --&gt;  p1        text
*&amp; &lt;--  p2        text
*&amp;---------------------------------------------------------------------*
FORM open_file_dialog USING p_path.
  DATA: ls_file_table LIKE LINE OF gt_file_table,
        lv_rc         TYPE i.
  CLEAR p_path.
  REFRESH: gt_file_table.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title     = 'Select File'
      default_filename = '*.pdf'
      multiselection   = 'X'
    CHANGING
      file_table       = gt_file_table
      rc               = lv_rc.
  READ TABLE gt_file_table INDEX 1 INTO ls_file_table.
  p_path = ls_file_table-filename.
ENDFORM.
*&amp;---------------------------------------------------------------------*
*&amp; Form UPLOAD_FILE
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; --&gt;  p1        text
*&amp; &lt;--  p2        text
*&amp;---------------------------------------------------------------------*
FORM upload_file USING p_path.
  DATA:    lv_len TYPE i.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename   = p_path
      filetype   = 'BIN'
    IMPORTING
      filelength = lv_len
    TABLES
      data_tab   = gt_content.
  PERFORM exception.
ENDFORM.
*&amp;---------------------------------------------------------------------*
*&amp; Form CONVERT_TO_BIN
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; --&gt;  p1        text
*&amp; &lt;--  p2        text
*&amp;---------------------------------------------------------------------*
FORM convert_to_bin .

  CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
    EXPORTING
      it_contents_bin = gt_content[]
    IMPORTING
      et_contents_bin = gt_content[].
  PERFORM exception.
ENDFORM.
*&amp;---------------------------------------------------------------------*
*&amp; Form GET_FOLDER_ROOT_ID
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; --&gt;  p1        text
*&amp; &lt;--  p2        text
*&amp;---------------------------------------------------------------------*
FORM get_folder_root_id .
  CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
    EXPORTING
      region    = 'B'
    IMPORTING
      folder_id = gs_fol_id
    EXCEPTIONS
      OTHERS    = 1.
  PERFORM exception.
ENDFORM.
*&amp;---------------------------------------------------------------------*
*&amp; Form SAP_OFFICE_OBJECT
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; --&gt;  p1        text
*&amp; &lt;--  p2        text
*&amp;---------------------------------------------------------------------*
FORM sap_office_object USING p_vbeln.
  DATA:
    ls_obj_data TYPE sood1,
    lt_objhead  TYPE STANDARD TABLE OF soli.

  ls_obj_data-objsns   = 'O'.
  ls_obj_data-objla    = sy-langu.
  ls_obj_data-objdes   = gv_fname.
  ls_obj_data-file_ext = gv_ext.
  ls_obj_data-objlen   = lines( gt_content ) * 255.
  CONDENSE ls_obj_data-objlen.
  CALL FUNCTION 'SO_OBJECT_INSERT'
    EXPORTING
      folder_id             = gs_fol_id
      object_type           = 'EXT'
      object_hd_change      = ls_obj_data
    IMPORTING
      object_id             = gs_obj_id
    TABLES
      objhead               = lt_objhead
      objcont               = gt_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.
  PERFORM exception.
ENDFORM.
*&amp;---------------------------------------------------------------------*
*&amp; Form CREATE_BINARY_RELATION
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; --&gt;  p1        text
*&amp; &lt;--  p2        text
*&amp;---------------------------------------------------------------------*
FORM create_binary_relation USING p_vbeln p_botype.
  DATA:
    ls_folmem_k TYPE sofmk,
    ls_note     TYPE borident,
    lv_ep_note  TYPE borident-objkey,
    ls_object   TYPE borident.
  ls_object-objkey = p_vbeln.
  ls_object-objtype = p_botype.
  ls_note-objtype   = 'MESSAGE'.
  CONCATENATE gs_fol_id-objtp gs_fol_id-objyr gs_fol_id-objno gs_obj_id-objtp gs_obj_id-objyr gs_obj_id-objno INTO ls_note-objkey.
  CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
    EXPORTING
      obj_rolea    = ls_object
      obj_roleb    = ls_note
      relationtype = 'ATTA'
    EXCEPTIONS
      OTHERS       = 1.
  PERFORM exception.
ENDFORM.
*&amp;---------------------------------------------------------------------*
*&amp; Form SPLIT_FILE_PATH
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp;      --&gt; P_PATH
*&amp;      --&gt; P_EXT
*&amp;      --&gt; P_FNAME
*&amp;---------------------------------------------------------------------*
FORM split_file_path  USING    p_path.
  DATA: lv_filename TYPE pcfile-path.
  CHECK p_path IS NOT INITIAL.
  lv_filename = p_path.
  CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
      complete_filename = lv_filename
*     CHECK_DOS_FORMAT  =
    IMPORTING
*     DRIVE             =
      extension         = gv_ext
*     NAME              =
      name_with_ext     = gv_fname
*     PATH              =
    EXCEPTIONS
      invalid_drive     = 1
      invalid_extension = 2
      invalid_name      = 3
      invalid_path      = 4
      OTHERS            = 5.
  PERFORM exception.
ENDFORM.
*&amp;---------------------------------------------------------------------*
*&amp; Form EXCEPTION
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; --&gt;  p1        text
*&amp; &lt;--  p2        text
*&amp;---------------------------------------------------------------------*
FORM exception .
  IF sy-subrc <> 0.
    MESSAGE ID     sy-msgid
          TYPE   sy-msgty
          NUMBER sy-msgno
          WITH   sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form import_gos
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM import_gos USING p_key p_path p_botype.

  DATA : wa_object       TYPE sibflporb,
         int_rel_options TYPE obl_t_relt,
         wa_rel_options  TYPE obl_s_relt,
         int_links       TYPE obl_t_link,
         wa_links        TYPE obl_s_link.
  wa_rel_options-low = 'ATTA'. "" Attachemnts
  wa_rel_options-sign = 'I'.
  wa_rel_options-option = 'EQ'.
  APPEND wa_rel_options TO int_rel_options.
  wa_object-instid = p_key.
  wa_object-typeid = p_botype. "" PR
  wa_object-catid  = 'BO'. "" Business Object
  REFRESH int_links[].
  TRY.
      CALL METHOD cl_binary_relation=>read_links_of_binrels
        EXPORTING
          is_object           = wa_object          " Start object
          it_relation_options = int_rel_options    " Link Types
          ip_role             = 'GOSAPPLOBJ'       " Role type
        IMPORTING
          et_links            = int_links.         " Table with Relationship Records
    CATCH cx_obl_parameter_error. " Incorrect Calling of Interface
    CATCH cx_obl_internal_error.  " Internal Error of Relationship Service
    CATCH cx_obl_model_error.     " Error with Model Roles
  ENDTRY.


  DATA : lv_doc_id      TYPE sofolenti1-doc_id,
         int_cont_bin   TYPE TABLE OF solisti1,
         int_cont_solix TYPE TABLE OF solix,
         wa_doc_data    TYPE sofolenti1.
  LOOP AT int_links INTO wa_links.
    lv_doc_id = wa_links-instid_b.
    REFRESH int_cont_bin[].
    REFRESH int_cont_solix[].
    CALL FUNCTION 'SO_DOCUMENT_READ_API1'
      EXPORTING
        document_id                = lv_doc_id
      IMPORTING
        document_data              = wa_doc_data
      TABLES
        contents_hex               = int_cont_solix
        object_content             = int_cont_bin
      EXCEPTIONS
        document_id_not_exist      = 1
        operation_no_authorization = 2
        x_error                    = 3
        OTHERS                     = 4.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

    DATA: lv_lines    TYPE char20,
          lv_doc_size TYPE i,
          lv_xstring  TYPE xstring.
    IF int_cont_solix IS NOT INITIAL.
      IF wa_doc_data-obj_type = 'TXT'.
        lv_lines = lines( int_cont_solix ) * 255.
        SHIFT lv_lines LEFT DELETING LEADING ' '.
        lv_doc_size = lv_lines.
      ENDIF.
      "" Convert the binary data to Xstring
      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = lv_doc_size
        IMPORTING
          buffer       = lv_xstring
        TABLES
          binary_tab   = int_cont_solix
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
      IF sy-subrc <> 0.
* Implement suitable error handling here
      ENDIF.
    ELSE.
      CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
        EXPORTING
          ip_solitab  = int_cont_bin
        IMPORTING
          ep_solixtab = int_cont_solix.
*
      IF wa_doc_data-obj_type = 'TXT'.
        lv_lines = lines( int_cont_solix ) * 255.
        SHIFT lv_lines LEFT DELETING LEADING ' '.
        lv_doc_size = lv_lines.
      ENDIF.
*
      "" Convert the binary data to Xstring
      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = lv_doc_size
        IMPORTING
          buffer       = lv_xstring
        TABLES
          binary_tab   = int_cont_solix
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
      IF sy-subrc <> 0.
* Implement suitable error handling here
      ENDIF.
      DATA:    lv_len TYPE i.
    ENDIF.
      data l_filename type string.
      CONCATENATE P_PATH wa_doc_data INTO l_filename SEPARATED BY '\'.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
*         BIN_FILESIZE                    =
          filename = l_filename
          filetype = 'BIN'
*         APPEND   = ' '
*         WRITE_FIELD_SEPARATOR           = ' '
*   IMPORTING
*         FILELENGTH                      =
        TABLES
          data_tab = int_cont_solix.

  ENDLOOP.
ENDFORM.

******* PROGRAMA ZSZK

REPORT zszk.

DATA: gt_file_table TYPE filetable,   "Uploaded file information
      gt_content    TYPE soli_tab,    "Uploaded files content
      gs_fol_id     TYPE soodk,       "Folder ID
      gs_obj_id     TYPE soodk.       "Object ID
DATA: gv_ext   TYPE sood1-file_ext,   "File extension
      gv_fname TYPE sood1-objdes.     "File name
INCLUDE zszkf01.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
  PARAMETERS: p_path  TYPE string OBLIGATORY.                    "File path
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.
  PARAMETERS: p_botype TYPE tojtb-name OBLIGATORY DEFAULT 'ZSZK', "Business obj type
              "p_doc_no TYPE vbeln OBLIGATORY.     "Business document number
              p_key    LIKE swotobjid-objkey,
              p_imp    AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b2.

INITIALIZATION.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
  PERFORM open_file_dialog USING p_path.            "Open file upload dialog box

START-OF-SELECTION.
  IF p_imp IS INITIAL.
    PERFORM upload_file USING p_path.                  "Upload file
    PERFORM convert_to_bin.                      "Convert file content to BIN
    PERFORM get_folder_root_id.                  "Get folder ID
    PERFORM split_file_path USING p_path.         "Find file extension and file name
    PERFORM sap_office_object USING p_KEY.          "Create SAP office object
    PERFORM create_binary_relation USING p_KEY p_botype. "Link office object and ment
  ELSE.
    PERFORM import_gos USING p_key p_path p_botype.
  ENDIF.