Showing posts with label SAP. Show all posts
Showing posts with label SAP. Show all posts

Wednesday, 22 September 2021

Adjustment of Withholding Tax Information to Relevant Types

 

Error: Auto Payment (F110)

    สาเหตุที่ระบบไม่สามารถเลือก Invoice มาตัดจ่ายได้ที่ Step: Proposal  เนื่องจากมีการเปลี่ยนแปลงบางข้อมูลของ Invoice เช่น Payment method, House bank, Withholding tax information ฯลฯ  ดังนั้นวิธีการแก้ไข ให้ทำตาม 2 ขั้นตอนด้านล่างก่อน



ขั้นตอนการแก้ไข

ขั้นตอนที่ 1 - เข้า T-Code:  SA38 และกรอกข้อมูลตามภาพ


ขั้นตอนที่ 2 - Delete Proposal เดิม และทำการ Run Proposal ใหม่อีกครั้ง

Sunday, 15 August 2021

SAP ABAP - Generating Excel file for downloading or sending over email

 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.

DATAlo_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.

DATAg_xstring  TYPE xstring.

*-- Get data from database into internal table
SELECT FROM mara INTO TABLE @DATA(lt_maraUP 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
=>downloadEXPORTING 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

Wednesday, 4 November 2020

SAP PO/PI sFTP FileName

 

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.


https://blogs.sap.com/2017/11/03/sap-pi-sftp-server-authentication/?utm_source=dlvr.it&utm_medium=facebook


Monday, 9 September 2019

Implement standard source code from SAP Note

How to implement standard source code from SAP Note
1. Open Link : KBA/SAP Note
2. Download : SAR File
3. Tcode : SNOTE


4. Navigate to the menu Goto -> Download SAP Note

5. Enter the Note Number and Execute

Friday, 22 February 2019

How to set and get value on table TVARVC

Set 

SM30 > Table/View = TVARV


GET

Function : Z_INITIAL_VALUE_GET

CLEAR gr_hkont.
  CALL FUNCTION 'Z_INITIAL_VALUE_GET'
    EXPORTING
*     IM_REPID = SY-CPROG
      im_filed 'HKONT'
    TABLES
      tr_data  gr_hkont.

Monday, 21 January 2019

How to add budget



Create Budget Document

Step 1: Tcode FMBBC
Step 2: Key data & Save

Release Budget Data

Step 1: Tcode FMMPRELE
Step 2: Key Data & Execute

Monday, 24 December 2018

No commitment item entered in item


Tcode : SPRO

Public Sector Management >
     Funds Management Government >
          Actual and Commitment Update/Integration >
               Activate/Deactivate Funds Management


Or Config at Tcode : FMDERIVE

Wednesday, 20 June 2018

Font Substritution

Courier New              MS Sans Serif
Courier              MS Sans Serif
Arial              Arial
Times New Roman      MS Sans Serif
Helv              MS Sans Serif
Tms Rmn      MS Sans Serif
Times              MS Sans Serif

Tuesday, 13 March 2018

Call Transaction FK03

SET PARAMETER ID'LIF' FIELD w_output-lifnr,
                            'BUK' FIELD p_bukrs,
                            'KDY' FIELD '/110/120/130/210/215/220/610'.
          CALL TRANSACTION 'FK03' AND SKIP FIRST SCREEN.

Sunday, 15 October 2017

Delete WBS Element

1. TCode OPSX : Check Budget
2. TCode CJ20N : Delete Project and Sub Project
3. Table VSPRPS_CN : Delete WBS Element by function SE16N_INTERFACE

Wednesday, 10 May 2017

How to Reset different SAP buffers

SAP Buffers can be reset with below commands :

  1. /$SYNC - Resets the buffers of the application server
  2. /$CUA - Resets the CUA buffer of the application server
  3. /$TAB - Resets the TABLE buffers of the application server
  4. /$NAM - Resets the nametab buffer of the application server
  5. /$DYN - Resets the screen buffer of the application server
  6. /$ESM - Resets the Exp./ Imp. Shared Memory Buffer of the application server
  7. /$PXA - Resets the Program (PXA) Buffer of the application server.
  8. /$OBJ - Resets the Shared Buffer of the application server.
SU53 and click authorization values —> Reset User Buffer.
SU01 -> environment -> mass changes -> reset all user buffers
Executing transaction PFUD or running program RHAUTUPD_NEW
se38 and program: RSUSR405

Ref. https://wiki.scn.sap.com/wiki/display/Basis/How+to+Reset+different+SAP+buffers

Wednesday, 15 March 2017

Transaction

Transaction Description

cf01,02,03 Production Resoure/Tool (PRT)
cmod                Project Management of SAP Enhancements
cr01,02,03 Work Center Capacity
db13                Check Tape Backup
mb52               Check Stock Material
mmpv              Close Period for Material Master Records
msc1n              Create Batch
oaor                 Upload Word and Excel File
pa40                Personal Actions (สถานะการทำงาน)
pdsy                HR Documentation ไว้ดูฟังก์ชันสำหรับเขียน Schema
pe01                Schema Editor
pe02                Personal Calculation Rules (PCR)
pe04                Maintain Function and Operation
pfcg                 Create Role
se03                 ใช้สำหรับ Release จาก DEV ไปที่ QA
se11                 Database Table, Type
se16n               เรียกดู Table
se19                 BADI
se20                 Enhancements
se22                 Check Error
se24                 Class
se30                 ใช้ดูค่า Config / ABAP Runtime Analysis
se37                 Function Module
se61                 Document Maintenance
se71                 Form Painter, SAPScript
se80                 หน้า Object Navigator
se91                 Message Class
se93                 Create Transaction Code
shdb                 Create Screen BDC
sm12                Table Lock
sm30                Maintain Table View, เพิ่มข้อมูล Table แบบ Config
sm36                Define Background Job
sm50                Check Process Job
sm59                Configuration of RFC Connections
smartforms      SAP Smart Forms
snro                 Number Range
so10                 สำหรับ Print, สร้าง Standard Text, Include Text
spad                 เกี่ยวกับการ Print
spro                 User Exit, Customizing
st05                 Performance Analysis
st22                 Error Message ของ User
stms                Transport Request
su01                Edit Password User or Lock, Unlock
su10                User Maintenance
su3                  สำหรับ Set Default Printer

Sunday, 12 March 2017

Class Timer in PBO Screen


Declaration Variable


   CLASS  xcl_event_receiver      DEFINITION DEFERRED.
   DATAxo_timer  TYPE  REF TO cl_gui_timer.
   DATAxo_event  TYPE  REF TO xcl_event_receiver.

          ___________________________________________________________________________


CLASS xcl_event_receiver DEFINITION.
  PUBLIC SECTION.

    CLASS-METHODS:
      timer_finished       FOR EVENT  finished
                                  OF  cl_gui_timer.

ENDCLASS.               

CLASS xcl_event_receiver IMPLEMENTATION.

      METHOD timer_finished.
             Do anything....
   ENDMETHOD
               
ENDCLASS.       

          ___________________________________________________________________________

PBO : Status_0100

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'TOOLBAR'.
  
  IF xo_timer IS INITIAL.
    CREATE OBJECT xo_timer
      EXCEPTIONS
        OTHERS 4.

    CHECK sy-subrc EQ  0.
    CREATE OBJECT xo_event.
  ENDIF.

  SET HANDLER xo_event->timer_finished FOR xo_timer.

  xo_timer->interval 1.

  "Create Container and ALV...

  xo_timer->run).

ENDMODULE.

Get Extension File

Func : TRINT_FILE_GET_EXTENSION

ABAP Easy Message Log

type-pools: ESP1 .
data:
LT_MESSAGE_TAB type ESP1_MESSAGE_TAB_TYPE ,
LS_MESSAGE_TAB type ESP1_MESSAGE_WA_TYPE.
         LS_MESSAGE_TAB-MSGID = 'AD' .
         LS_MESSAGE_TAB-MSGTY = 'W' .
         LS_MESSAGE_TAB-MSGNO = '010' .
         LS_MESSAGE_TAB-MSGV1 = TEXT-001.
append LS_MESSAGE_TAB to LT_MESSAGE_TAB .
call function 'C14Z_MESSAGES_SHOW_AS_POPUP'
tables
             I_MESSAGE_TAB = LT_MESSAGE_TAB.

Reading URL of GOS

by using Function module              SO_OBJECT_READ



 * Set folder
  l_folder_id-objtp = document_id-foltp.“FOL  
  l_folder_id-objyr = document_id-folyr.“29
  l_folder_id-objno = document_id-folno.“000000000004
* Set Object
  l_object_id-objtp = document_id-doctp.“URL   
  l_object_id-objyr = document_id-docyr.“38
  l_object_id-objno = document_id-docno.“000000001457
*
  CALL FUNCTION 'SO_OBJECT_READ'
    EXPORTING
     folder_id                  l_folder_id
      object_id                  l_object_id
    TABLES
      objcont                    document_content

instid_b can be get from  1)  table: SRGBTBREL 2) cl_binary_relation=>read_links from http://zevolving.com/2009/02/generic-object-services-gos-toolbar-part-5-get-note-attachment-contents/


PARAMETERSp_ord TYPE afko-aufnr.
*
START-OF-SELECTION.
*
*---------
* Get all the NOTE attached to Business object
*---------
*
* buseinss object key
  DATAgs_lpor TYPE sibflporb.

  gs_lpor-instid p_ord. “Prd Order 
  gs_lpor-typeid 'BUS2005'.
  gs_lpor-catid  'BO'.

* attachment type selection
  DATAlt_relat TYPE obl_t_relt,
        la_relat LIKE LINE OF lt_relat.

  la_relat-sign 'I'.
  la_relat-option 'EQ'.
  la_relat-low 'URL'.
 APPEND la_relat TO lt_relat.

* Read the links
  DATAt_links TYPE obl_t_link,
        la_links LIKE LINE OF t_links.

  DATAlo_root TYPE REF TO cx_root.

  TRY.
      CALL METHOD cl_binary_relation=>read_links
        EXPORTING
          is_object           gs_lpor
          it_relation_options lt_relat
        IMPORTING
          et_links            t_links.
    CATCH cx_root INTO lo_root.
  ENDTRY.

*---------
* Read NOTE contents
*---------
  DATA l_folder_id TYPE soodk.
  DATA l_object_id TYPE soodk.
  DATA document_id       TYPE sofmk.
* Get document id
  READ TABLE t_links INTO la_links INDEX 1.
  document_id la_links-instid_b.

* Set folder
  l_folder_id-objtp document_id-foltp.
  l_folder_id-objyr document_id-folyr.
  l_folder_id-objno document_id-folno.

* Set Object
  l_object_id-objtp document_id-doctp.
  l_object_id-objyr document_id-docyr.
  l_object_id-objno document_id-docno.

* Read the document content
  DATA document_content  TYPE STANDARD TABLE OF soli.

  CALL FUNCTION 'SO_OBJECT_READ'
    EXPORTING
      folder_id                  l_folder_id
      object_id                  l_object_id
    TABLES
      objcont                    document_content.