Friday, January 30, 2015

SAP TIP Change-Document


Chapter 088
Change-Document
Source : http://abapjoy.blogspot.com

Sometimes, we need to track who changed the sap standard transaction data. The tables of CDHDR AND CDPOS contain the all sap change log, but this is restricted to the case when the proper setting is made.

CDHDR : Header table for change log
CDPOS : Item table  for change log

Like upper screen capture, if the setting for change document is set, all changes with this data element is saved to the log table.
In addion, you can create extra change document object with the t-code: SCD0

The bellows are the functions which are related to change logs.

CHANGEDOCUMENT_READ_HEADERS    Change document: Read change document header
CHANGEDOCUMENT_READ_POSITIONS  Change document: Read change document items
CHANGEDOCUMENT_PREPARE_POS     Change document: Edit change document items
CHANGEDOCUMENT_READ             Change document : Read and edit



Thursday, January 29, 2015

SAP TIP What is BTE(business transaction events)




Chapter 087
What is BTE(business transaction events)
Source : http://abapjoy.blogspot.com

BTE is a extension tool for only FI module like customer exit for the extra customer business requirement. That is, we can implement the extra functions which SAP doesn't provide in standard program. The source SAP standard program calls the BTE is written like [figure 1], which is set as "OPEN_FI_PERFORM + BTE PROCESS sequence" .


[Figure 1.  Script for calling BTE]

[Figure 2] shows how sap standard program calls the BTE function module each process, this is only allowed with the point SAP already specified in the program. 

[Figure 2 BTE flow chart]

BTE can be adapted with the IMG(T-CODE:SPRO)﾿ᄀᄐᆳ ᄌ￞ᄡᄎFinancial Accounting -> Financial Accounting Global Settings -> Business Transaction Events or execute T-CODE:FIBF.

  1. T-CODE:FIBFᄌᆭ : chose the menu Environment-> Infosystem (Processes)
  2. execute the program leaving the devalue value









  3. you can select the line and press the button  .









  4. T-CODE:SE37 is opened and sample function code is set. You need to copy the function by pressing the button. ( )









ABAP TIP ALV USER COMMAND

Chapter 086
ALV USER COMMAND.
Source : http://abapjoy.blogspot.com

Generally, we implement the ALV button action for the event that user push the button.
1. ALV Level : ALV Event implementation
METHOD handle_command.
    DATA : l_scroll TYPE lvc_s_stbl.

    CASE e_ucomm.
      WHEN 
‘ALV command’.
          ‘Implementation of method ~~’.
    ENDCASE.
  ENDMETHOD.                    "handle_user_command

There is another useful way to integrate all user action of ALV within SCREEN level.
 When user click the button on ALV, if you call the method SET_NEW_OK_CODE of class CL_GUI_CFW,
you can implement the same function of calling alv hander method. That is, the user command on ALV to screen PBO module.

1. ALV event
      
METHOD handle_command.
    DATA : l_scroll TYPE lvc_s_stbl.

    CASE e_ucomm.
      WHEN 
‘ALV command’.
         CALL METHOD cl_gui_cfw=>set_new_ok_code
        
EXPORTING
             new_code = ‘ALV command’.
 

    ENDCASE.
  ENDMETHOD.                    "handle_user_command

 2. screen PAI command implementation.
MODULE user_command_0100 INPUT.

  CASE sy-ucomm.
    WHEN 
‘ALV command’.
       ‘implement of alv function’
NDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT




Wednesday, January 28, 2015

ABAP TIP ABAP Graphic Proxies


Chapter 085
ABAP Graphic Proxies
Source : http://abapjoy.blogspot.com


There was a request of displaying the graphic with the sap data from user. I have implemented like below.
[Figure1, ABAP Graphic program]


You can easily develop the program with the help of SAP demo program.
SAP documents
- BCFESGRA (SAP Graphics)
- BCFESGRA2 (BC SAP Graphics : Programming Interfaces )
T-code
- GRAL
Development Class
- SGRB



ABAP TIP ALV Color sample program


Chapter 084
ALV Color sample program
Source : http://abapjoy.blogspot.com


When creating ALV report program, the one we should implement is to set the color in line and text. This post offers a sample program and alv color code.



REPORT  ZALVCOLOR.

TYPE-POOLS: SLIS.

DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA: BEGIN OF I_OUTPUT OCCURS 0,
        I_TEXT(30) TYPE C,
        I_COLOR(4),
      END OF I_OUTPUT.

DATA: I_NUM(1) TYPE N.
DATA: I_INT(1) TYPE N.
DATA: I_4(1)   TYPE N.

DO 28 TIMES.
  I_4 = 0.
  IF SY-INDEX = 1.
    I_NUM = 1.
    I_INT = 1.
  ELSE.
    I_NUM = I_NUM + 1.
    IF I_NUM = 8.
      I_NUM = 1.
      I_INT = 0.
    ENDIF.
  ENDIF.
  IF SY-INDEX > 14.
    I_4 = 1.
  ENDIF.
  IF SY-INDEX > 21.
    I_INT = 1.
  ENDIF.

  CONCATENATE 'C' I_NUM I_INT I_4 INTO I_OUTPUT-I_COLOR.
  CONCATENATE 'COLOR ' I_OUTPUT-I_COLOR INTO I_OUTPUT-I_TEXT SEPARATED BY SPACE.
  APPEND I_OUTPUT.
  CLEAR I_OUTPUT.
ENDDO.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'I_TEXT'.
LS_FIELDCAT-SELTEXT_L = 'ALV COLOR VIEW'.
LS_FIELDCAT-KEY = 'X'.
LS_FIELDCAT-OUTPUTLEN = '30'.
APPEND LS_FIELDCAT TO FIELDCAT.

LAYOUT-INFO_FIELDNAME = 'I_COLOR'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM = 'Z_SET_COLOR_IN_ALV_OUTPUT'
    IS_LAYOUT          = LAYOUT
    IT_FIELDCAT        = FIELDCAT[]
  TABLES
    T_OUTTAB           = I_OUTPUT[].



ABAP TIP Data creation for sap demo table


Chapter 083
Data creation for sap demo table
Source : http://abapjoy.blogspot.com


There are demo tables for SAP lecture or SAP IDES server. That is, we use the tables like SCARR, SFLIGHT, SBOOK which are related to airline system. In some customer sap server, there is no data for demo tables. We can create demo data using the program.

Program Name : SAPBC_DATA_GENERATOR, T-code : BC_DATA_GEN


If you execute this program, there will be options according to the amount of data volume.

After execution, you will see the data in demo tables.



Tuesday, January 27, 2015

ABAP TIP SAP Web Repository File Upload download



Chapter 082
SAP Web Repository File Upload download
Source : http://abapjoy.blogspot.com


Lets see how to upload/download file to the sap.

1.  File Upload
   Transaction Code : SMW0

- check Binary data for WebRFC applications and execute

- Input object name, Description and upload file by upload icon.

2. File download with functioin

SELECT SINGLE  *
    INTO CORRESPONDING FIELDS OF LS_WWWDATATAB
    FROM WWWDATA                 "
   WHERE OBJID = object name you input when uploading.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
    EXPORTING
      KEY         = LS_WWWDATATAB
      DESTINATION = the full destination folder and name
Ex) C:\XXX\YYY.xlsx



ABAP TIP Remove and inactivate buttons in application toolbar




Chapter 082
Remove and inactivate buttons in application toolbar
Source : http://abapjoy.blogspot.com


What is user parameter and the relation between SAP memory?

User parameter is SAP memory. It provides user function to set a default value in program which user often uses or when authority check is needed.
Via T-CODE:SU3, you can set the user profile for each SAP USER.  All SAP parameter can be used as a user parameter. But SAP memory is not only used for user profile.

In order to create SAP memory, you need to select the menu : Program -> Other object in ABAP editor.

Move to More..tab and input the SET/GET Parameter ID and click the create icon.


Now, new parameter ID is created.

You can add the SAP memory in user profile and set the value in this parameter.
From now on, you parameter value is set whenever you log in SAP.