Archive

Archive for the ‘ABAP’ Category

SAP FI – Deductible and Non-deductible Tax

February 6th, 2012 No comments

Non-deductible taxes are taxes that are not allowable when calculating a taxable income. They are taxes that have been paid in the process of generating income or purchasing items, but they are not subtracted from the final taxable income. For example,

VAT 14% non-deductible 50%

100 EUR invoice (account 5080) 
7 EUR VAT goes to the VAT account 
7 EUR VAT goes back to the Expense account (5080)
Total invoice 107.00
Total VAT 7.00

How to configuration this scenario in SAP?

In Tax code A2, Enter 7% in condition type MWAS and 7% in condition type MWVZ.

Read more…

SAP FI – Coding Block

February 2nd, 2012 No comments

In the coding block of the system you can create your own fields. The new coding fields can then be used in FI General Ledger accounts, MM Inventory Management and MM Purchasing, and are also updated in the line items created in the Controlling applications.

If you have created customer fields, they are updated by the system during automatic postings. To enable you to post these fields in the Enjoy transactions manually, you must assign the fields to the entry variants in the Enjoy posting transactions. To do this, choose Include Customer Fields in Enjoy Transactions.

Requirements

You require a test system in order to include coding fields.

The changes are recorded in the test system in a transport request and can thus be transported into other systems. To include coding fields, you require the following authorizations:

  • New field inclusion in coding block X_COBLMOD
  • Maintenance of cross-client tables S_TABU_CLI
  • Dictionary authorization S_DEVELOP
  • Transport authorization S_TRANSPRT

Read more…

How to hide SAP standard button in standard transaction

February 2nd, 2012 No comments

Business user might need to hide some buttons in SAP standard transaction code because they don’t want there functions to be abused. We assume there function couldn’t be controlled by authorization objects. SAP provides transaction variant to change SAP standard UI.

Transaction variants can simplify transaction runs as they allow you to:

  • Preassign values to fields
  • Hide and change the ‘ready for input’ status of fields
  • Hide and change table control column attributes
  • Hide menu functions
  • Hide entire screens
    In particular, hiding fields in connection with screen compression, and hiding screens, can result in greater clarity and simplicity.

Transaction variants are made up of a sequence of screen variants. The field values and field attributes for the individual screens found in transaction variants are stored in screen variants. Each of these variants is assigned to a specific transaction, can, however, also contain values for screens in other transactions if this is required by transaction flow. The transaction that the variant is assigned to serves as initial transaction when the variant is called.

For example, if we need to hide button ‘Reject document’ in tcode VA02. Below are the detail steps.

Read more…

SAP ABAP – Transfer number to chinese character function module

January 9th, 2012 No comments

Only Chinese Project will use this funtion module.Usually in account document print.

To english character,we can use spell_amout.

FUNCTION z_convert_numeric_to_chinese.
*";----------------------------------------------------------------------
*";*";Local interface:
*";  IMPORTING
*";     REFERENCE(PI_MONEY) LIKE  BSEG-DMBTR
*";  EXPORTING
*";     REFERENCE(PO_CHINESE)
*";  EXCEPTIONS
*";      WRONG_MONEY
*";----------------------------------------------------------------------
  IF pi_money = 0.
    po_chinese = '零'.
    EXIT.
  ENDIF.
  DATA:money_str(13).
  money_str = pi_money.
  IF money_str CN '0123456789. '.
    RAISE wrong_money.
  ENDIF.
  DATA:i TYPE i.
  IF money_str CS '.'.
    i = sy-fdpos + 1.
 
    money_str+sy-fdpos = money_str+i.
  ENDIF.
  CONDENSE money_str NO-GAPS.
  DATA:units_off TYPE i,
         curnt_off TYPE i.
  DATA:lastd TYPE n,curntd TYPE n.
  DATA:cword(2),weight(2).
  DATA:units(30) VALUE ' 分 角 元 拾 佰 仟 万 拾 佰 仟 亿 拾 佰 仟 万',
         digts(20) VALUE ' 零 壹 贰 叁 肆 伍 陆 柒 捌 玖'.
  CLEAR:po_chinese,units_off.
  lastd = 0.
  units_off = 0.
  curnt_off = STRLEN( money_str ) - 1.
  WHILE curnt_off >;= 0.
    curntd = money_str+curnt_off(1).
    i = curntd * 2.
    cword = digts+i(2).
 
    weight = units+units_off(2).
 
    i = units_off / 2.
    IF curntd = 0.             ";Current digit is 0
      IF i = 2 OR i = 6 OR i = 10.
        CLEAR:cword.
        IF curnt_off = 0.
          CLEAR:weight.
        ENDIF.
      ELSEIF lastd = 0.
        CLEAR:cword,weight.
      ELSE.
        CLEAR:weight.
      ENDIF.
    ENDIF.
    CONCATENATE cword weight po_chinese INTO po_chinese.
    lastd = curntd.
    SUBTRACT 1 FROM curnt_off.
    ADD 2 TO units_off.
  ENDWHILE.
  IF po_chinese NS '分'.
    CONCATENATE po_chinese '整' INTO po_chinese.
  ELSE.
    cword = po_chinese.
    IF cword = '零'.
      SHIFT po_chinese BY 2 PLACES.
    ENDIF.
  ENDIF.
*-----------------BEGIN----------------------------
*&; 当数值为100,000,000.01 时,调用该函数
*&; ,显示出来为壹亿万元零壹分,加上该段
*&; ,则读为壹亿元零壹分。
  SEARCH po_chinese FOR '亿 万'.
  IF sy-subrc = 0.
    REPLACE '亿 万' WITH '亿' INTO po_chinese.
  ENDIF.
*-----------------END------------------------------
  CONDENSE po_chinese NO-GAPS.
 
 
 
ENDFUNCTION.

ABAP Programming – ABAP General

January 4th, 2012 No comments

The following diagram shows the components of SAP ABAP. Generally speaking, it contains the ABAP language, development environment, runtime environment, technologies that based on ABAP and other tools & services. All these components forms the ABAP (Advanced Business Application Programming).

In order to be a senior ABAP consultant, you should have a good command of all these components. I wants to share my personal experience on all these topics.

ABAP Overview

Read more…

ABAP Objects – Event and Observer Pattern

January 3rd, 2012 No comments

In ABAP Objects programming, event handling – event trigger and event handler means that certain methods act as triggers and trigger events, to which other methods – the handlers – react. This means that the handler methods are executed when the event occurs. This works exactly like the delegates and events in C#.

Both ABAP and C# programming language supports the event programming from language level. This feature can be used to implement observer pattern easily.  The observer pattern (a subset of the publish/subscribe pattern) is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. Below diagram illustrate the class diagram of observer pattern.

Observer Pattern

Read more…

SAP ALV – ALV Samples in SAP (cl_salv_table and cl_gui_alv_grid)

December 22nd, 2011 No comments

ALV is a very usual topic of the search keywords about ABAP.

Recently,I make some research about ALV,such like ALV tree,drag and drop effects of ALV,how to display two alv on one screen.

What is the difference between package SLIS and SALV_TABLE?

Before try to use the data,we should init data for flight sample and sbook sample of ALV.Program SAPBC_DATA_GENERATOR can init the data

of this two sample.

ALV_T_T2 is used for alv tree sample.We can init the data with function

module BCALV_GENERATE_ALV_T_T2.

Difference between SLIS and SALV_TABLE

1 cl_salv_table in package salv_table does not support editable grid,but SLIS can.

2 drag and drop effects of alv are only avaliable for SLIS

3 For full screen ALV,SALV_TABLE is much more easier to use.If we want to use SLIS to achieve the fullscreen effect,we only can use function module API to achieve this,with cl_gui_alv_grid is impossible.

 

There are still many points we can talk about  ALV.You can find many other blogs introducing ALV on sapgeek .Try to avoid repeating.I will focus on talking about some  other areas of ALV in later blogs,such like drag and drop effects,and then extends to SAP control framework(SAP GUI Programing)

SAP ALV- Control negative sign display for currency fields

December 5th, 2011 No comments

In SAP ALV, display minus singal ‘-’from left to right is very usual requirements.

We can implement this requirements throuth eidt mask feature of SAP ALV.

In class cl_salv_column_table ,there is a method set_edit_mask.

It is allowed to set own developed conversion routine here.

Just define ROUTINE named like ‘CONVERSION_EXIT_**_OUTPUT’.I will give a example later.

For curr Type fields, by default,the negative sign is not displayed in ALV.We should

use the method ‘SET_SIGN’ of class cl_salv_column_table to resolve this problem.

If we do not set sign for the column,when printing view or background processing the report,the result will not display ‘-’.

Changes and Transports for Client-Specific Objects

November 21st, 2011 No comments

In a typical SAP system landscape, you will have about 4-5 SAP clients for different purpose, such as sandbox client, development client, QA client, production client and training client. Each client has to have different client-specific settings on the client-specific objects changes and transports.

Go to tcode SCC4, you will find a list of clients on this system. Double click one client entry and you will enter below screen. You can maintain the client specific settings here.

Read more…

SAP BAPI – BAPI_MATERIAL_SAVEDATA

November 21st, 2011 No comments

SAP BAPI – BAPI_MATERIAL_SAVEDATA is the standard API to create/update the material master data. When creating material master data, you must transfer the material number, the material type, and the industry sector to the method. You must also enter a material description and its language. When changing material master data, you need enter only the material number. For detailed information on how to use this API, please refer to the function module documentation.