You are on page 1of 10

Best-Practices & Learnings ON

SAP ABAP Hard coding Angels & Demons

By
Prammenthiran Rajendran Prammenthiran.rajendran@wipro.com

Prammenthiran.rajendran@wipro.com 23 Dec 2!"!

Introduction#
$he word %hard coding& will ma'e an( SAP cons)ltant serio)s. *ons)ltants alwa(s do)+t the enhancement , reports , programs which has hard coded logic. Beca)se the( +elie-e that it ma( wor' temporaril( and not a permanent sol)tion to the re.)irement. So/ sho)ld it +e a-oided "!!01 As per m( SAP e2perience 3 can not sa( that hard coding has to +e a-oided "!!0. Hard coding has to +e )sed in most o4 the ABAP programming to meet the re.)irement. B)t the ABAP cons)ltant has to )nderstand what can +e hard coded/ how and wh(1 3 wo)ld li'e to di44erentiate good and +ad practices o4 hard coding in this doc)ment.

Scope
$his doc)ment is intended 4or ABAP cons)ltants. Also/ will help the 4)nctional cons)ltant to prepare a +etter 4)nctional speci4ication to a-oid rewor'ing. $he doc)ment will help the cons)ltant to )nderstand the hard coding concept with some samples which are ta'en 4rom the SAP projects.

Best-Practices/Learning
5enerall(/ ABAP cons)ltants )sed to hard code the -al)es as per the 4)nctional cons)ltant6s inp)t. B)t this does not mean that it is the complete responsi+ilit( o4 the 4)nctional cons)ltants 4or hard coding an( data. As a good ABAP cons)ltant/ we sho)ld 'now the impact o4 hard coding a c)stom data 7a partic)lar doc)ment t(pe or item categor( or sales organi8ation9 in o)r ABAP programs. $he +est practice is to get the SAP con4ig)ration , master le-el in4ormation 4or the partic)lar re.)irement which need hard coding. :e can alwa(s as' this in4ormation to the 4)nctional cons)ltant +e4ore starting the de-elopment. $he 4)nctional cons)ltant will de4initel( show the con4ig)ration 7SPR;9 path. $his will gi-e )s the con4ig)ration le-el detail where we can get the re.)irement technical in4ormation +( pressing <" 'e(. $he 4ollowing pages ha-e some samples which will help the cons)ltant to )nderstand the concept and appl( in the SAP projects in a +etter wa(.

Sample requirements with good and ad hard coding practices! "9 Re.)irement# =pdate the Sales order +illing +loc' 4or *redit memo re.)est/ de+it memo re.)est and ret)rn orders thro)gh )ser e2its. Bad Practice# Hard coding all the re.)ired doc)ment t(pes as +elow. 3mpact# $his will not wor' when we create a new doc)ment t(pe. So/ this enhancement needs code change whene-er there is a new doc)ment t(pe creation.

5ood Practice# Hard code the SD doc)ment categor( 7>BA? >B$@P9 which is the standard SAP con4ig)ration le-el data. $his will co-er all the c)stom doc)ment t(pes which e-er will +e created in 4)t)re as well.

Sample code 4or good practice#

:e can also get the doc)ment t(pe 4ield data 4rom the con4ig)ration ta+le $>A? i4 re.)ired 7$ransaction code >;>A9.

29 Re.)irement# Bna+le,disa+le a partic)lar 4eat)re +ased on the sales organi8ation and doc)ment t(pe. Bad practice# Hard coding the re.)ired sales organi8ation and doc)ment t(pe where e-er re.)ired as +elow/

5ood practice# Caintain a c)stom ta+le with Sales organi8ation and doc)ment t(pes as primar( 'e( with separate 4lags as +elow. So that we can e2tend the re.)ired 4eat)re to other sales organi8ation and doc)ment t(pes in 4)t)re. ;r ena+le , disa+le whene-er re.)ired.

39 Re.)irement# Print a partic)lar detail 4or the sales order onl( when it has it6s domestic plant 7Based on the compan( code co)ntr( and Plant code co)ntr(9.

Bad practice# Hard code the sales order plant code and compan( codes to chec' the speci4ic plants )nder the compan( codes. 5ood practice# *ompare the sales order6s compan( code co)ntr( 7$!!" Dand"9 and plant code co)ntr( 7$!!": Dand"9. 34 +oth are same then it is a domestic plant.

E9 Re.)irement# 3denti4( the wareho)se managed storage location and write the code as per the enhancement re.)irement. Bad practice# Hard code all the re.)ired wareho)se managed storage locations in the enhancement. 5ood practice# *hec' the entries in con4ig)ration ta+le $32! and identi4( the wareho)se managed storage location i4 wareho)se n)m+er 4o)nd as +elow.

F9 Re.)irement# Bnhancement sho)ld e2cl)de the sales order6s 4ree goods or witho)t price. Bad practice# Hard code the material codes ;R hard code item categor( ;R chec' the sales order item net -al)e 4ield 7GB$:R9 as 8ero ;R write a comple2 logic to chec' the pricing condition t(pe -al)e o4 the sales order item. 5ood practice# *hec' the con4ig)ration -al)e 7$>AP PRS<D9 4or the sales order or in-oice item categor( 7>BAP PS$@>9 as +elow. $his logic will ta'e care the 4)t)re item categories as well.

H9 Re.)irement# Bnhancement code sho)ld wor' onl( 4or Ret)rn deli-eries 7Deli-er( Doc)ment t(pe IDR9. Bad practice# Hard code the deli-er( doc)ment t(pe IDR as +elow/

5ood practice# Hard code the re.)ired deli-er( doc)ment categor( D3?P >B$@P which has +een )pdated 4rom the con4ig)ration ta+le. Ret)rn deli-er( doc)ment categor( J K$6 Gormal deli-er( doc)ment categor( J KL6 etc./

"onclusions
Hope (o) got some idea on good and +ad practices in hard coding. $he a+o-e samples are j)st to )nderstand the concept. So/ please as' (o)r 4)nctional cons)ltant to tell a+o)t the con4ig)ration le-el detail 4or the rele-ant hard coding area. Also/ it is alwa(s good to )nderstand the 4)nctional re.)irement tho)gh the cons)ltant is an ABAP de-eloper.

=se4)l Din's# Program to 4ind the hard coding in ABAP programs


http#,,www.a+ap t)torials.com,2!!M,!A,!E,trac' hard coding in programs,Nmore FO!

$han' (o)

You might also like