Error: Auto Payment (F110)
ขั้นตอนการแก้ไข
ขั้นตอนที่ 2 - Delete Proposal เดิม และทำการ Run Proposal ใหม่อีกครั้ง
Error: Auto Payment (F110)
ขั้นตอนการแก้ไข
ขั้นตอนที่ 2 - Delete Proposal เดิม และทำการ Run Proposal ใหม่อีกครั้ง
Creating excel content from data in an internal table?
Getting the following message when opening an excel created out of SAP - "The file you are trying to open, ‘filename.xls’ is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
Below is the best solution. This solution is based on the approach used by standard SAP to created excel content from ALV. Once any ALV is displayed, you can get the data into excel using the menu bar option LIST -> EXPORT -> SPREADSHEET.
If there are any questions, put them in the comments.
Sample working code:
*&---------------------------------------------------------------------*
*& Report Y_EXCEL
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Y_EXCEL.
DATA: lo_data TYPE REF TO data,
lt_fieldcatalog TYPE lvc_t_fcat,
l_flavour TYPE string, " Flavour for XML conversion
l_version TYPE string, " XML Version
lo_result_data TYPE REF TO cl_salv_ex_result_data_table, " Result data reference
l_file_type TYPE salv_bs_constant,
lt_xml_choice TYPE if_salv_bs_xml=>t_type_xml_choice,
ls_xml_choice TYPE if_salv_bs_xml=>s_type_xml_choice.
DATA: g_xstring TYPE xstring.
*-- Get data from database into internal table
SELECT * FROM mara INTO TABLE @DATA(lt_mara) UP TO 20 ROWS.
*-- Get object reference of the internal table holding the data
GET REFERENCE OF lt_mara INTO lo_data.
*-- Get the FieldCatalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'MARA' " The fields in the structure should match with those of the internal table
CHANGING
ct_fieldcat = lt_fieldcatalog
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
.
IF sy-subrc EQ 0.
*-- Prepare result data object using final table data reference
*-- and the fieldcatalog
CALL METHOD cl_salv_ex_util=>factory_result_data_table
EXPORTING
r_data = lo_data
t_fieldcatalog = lt_fieldcatalog
RECEIVING
r_result_data_table = lo_result_data.
IF lo_result_data IS NOT INITIAL.
*--- Get version of XML
CASE cl_salv_bs_a_xml_base=>get_version( ).
WHEN if_salv_bs_xml=>version_25.
l_version = if_salv_bs_xml=>version_25.
WHEN if_salv_bs_xml=>version_26.
l_version = if_salv_bs_xml=>version_26.
WHEN OTHERS.
" Do nothing
ENDCASE.
*--- Filetype: XLSX
l_file_type = if_salv_bs_xml=>c_type_xlsx.
*--- Flavour: Export
l_flavour = if_salv_bs_c_tt=>c_tt_xml_flavour_export.
*--- Transformation of data to excel
*--- GXSTRING will be used to send the email
CALL METHOD cl_salv_bs_tt_util=>if_salv_bs_tt_util~transform
EXPORTING
xml_type = l_file_type
xml_version = l_version
r_result_data = lo_result_data
xml_flavour = l_flavour
gui_type = if_salv_bs_xml=>c_gui_type_gui
IMPORTING
xml = g_xstring.
*-- Using Function Module "SCMS_XSTRING_TO_BINARY" we can convert G_XSTRING to Binary format and use that to send
*-- email using class CL_BCS
*-- Below is Sample code to download excel file
lt_xml_choice = cl_salv_export_xml_dialog=>get_gui_spreadsheet_formats( ).
READ TABLE lt_xml_choice INTO ls_xml_choice WITH KEY xml_type = l_file_type.
IF sy-subrc EQ 0.
cl_salv_export_xml_dialog=>download( EXPORTING s_xml_choice = ls_xml_choice
xml = g_xstring ).
ENDIF.
ENDIF.
ENDIF.
Ref: https://quick-drop.blogspot.com/2021/07/sap-abap-generating-xlsx-file-for.html
In SFTP server folder, files will be dropped with same original name by enabling ‘Adapter Specific Message-Attributes‘ and using %FileName% in ‘FileName’ input field
Filepath always start with symbol “~”, follow by the path.
Advanced tab:
Tick Use ASMA and Filename. Put namespace “http://sap.com/xi/XI/System/File” and Filename sttribute name “FileName”. This have the flexibility to put any namespace and attributes.
REPORT z_demo_alv_sort. *---------------------------------------------------------------------* * This program lists orders (VBAK) with sort and sub-total for * * 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG) * *---------------------------------------------------------------------* TABLES : vbak. TYPE-POOLS: slis. " ALV Global types SELECT-OPTIONS : s_vkorg FOR vbak-vkorg, " Sales organization s_kunnr FOR vbak-kunnr, " Sold-to party s_vbeln FOR vbak-vbeln. " Sales document SELECTION-SCREEN : SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY. SELECTION-SCREEN END OF LINE. DATA: BEGIN OF gt_vbak OCCURS 0, vkorg LIKE vbak-vkorg, " Sales organization kunnr LIKE vbak-kunnr, " Sold-to party vbeln LIKE vbak-vbeln, " Sales document netwr LIKE vbak-netwr, " Net Value of the Sales Order waerk LIKE vbak-waerk, " Document currency END OF gt_vbak. *---------------------------------------------------------------------* INITIALIZATION. v_1 = 'Maximum of records to read'. *---------------------------------------------------------------------* START-OF-SELECTION. PERFORM f_read_data. PERFORM f_display_data. *---------------------------------------------------------------------* * Form f_read_data *---------------------------------------------------------------------* FORM f_read_data. SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak FROM vbak UP TO p_max ROWS WHERE kunnr IN s_kunnr AND vbeln IN s_vbeln AND vkorg IN s_vkorg. ENDFORM. " F_READ_DATA *---------------------------------------------------------------------* * Form f_display_data *---------------------------------------------------------------------* FORM f_display_data. DEFINE m_fieldcat. add 1 to ls_fieldcat-col_pos. ls_fieldcat-fieldname = &1. ls_fieldcat-ref_tabname = 'VBAK'. ls_fieldcat-do_sum = &2. ls_fieldcat-cfieldname = &3. append ls_fieldcat to lt_fieldcat. END-OF-DEFINITION. DEFINE m_sort. add 1 to ls_sort-spos. ls_sort-fieldname = &1. ls_sort-up = 'X'. ls_sort-subtot = &2. append ls_sort to lt_sort. END-OF-DEFINITION. DATA: ls_fieldcat TYPE slis_fieldcat_alv, lt_fieldcat TYPE slis_t_fieldcat_alv, lt_sort TYPE slis_t_sortinfo_alv, ls_sort TYPE slis_sortinfo_alv, ls_layout TYPE slis_layout_alv. m_fieldcat 'VKORG' '' ''. m_fieldcat 'KUNNR' '' ''. m_fieldcat 'VBELN' '' ''. m_fieldcat 'NETWR' 'X' 'WAERK'. m_fieldcat 'WAERK' '' ''. m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal m_sort 'VBELN' ''. " Sort by vbeln ls_layout-cell_merge = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING is_layout = ls_layout it_fieldcat = lt_fieldcat it_sort = lt_sort TABLES t_outtab = gt_vbak. ENDFORM. " F_DISPLAY_DATA