ABAP: Good practices of programming

Hi all,
Somebody could indicate a document, URL or book with the best practices programming ABAP recommended by SAP?
Thanks in advance!

Hi,
Search in Google with "best practices in abap".
Thanks,
Sri.

Similar Messages

  • Good book learn Abap Objects ( Object Orineted Programming in Abap )

    Hi,
    Could you please suggest a nice book to learn ABAP objects.
    thanks.

    hi deepti
    These are the recommended books for OO programming in ABAP.
    1.ABAP Objects: The Official Reference
    by Horst Keller, Joachim Jacobitz
    This is systematic language reference book for ABAP Objects.
    2. ABAP Objects: Introduction to Programming SAP(R) Applications
    by Horst Keller, Sascha Kruger

  • How to use LDB PNP with ABAP objects in a program

    Hello,
    I am wondering if anybody has used the HR logical database(LDB) PNP with user defined ABAP objects in a program? I am using the FM- <b>LDB_PROCESS</b> but its not working. Also assigning PNP in the attributes section of the program -- so that I can use predefined fields from the LDB and then invoking the FM doesn't work -- throwing 'Logical database already active' error.
    I suppose even with the ABAP objects and the new FM -- I should still be able to utilize the pre-defined fields of the PNP database -- and also the built in authorizations. I cannot use GET PERNR and REJECT as they give errors. I understand that the use of HR-macros (RP-PROVIDE-FROM-LAST and et al.) are not allowed as they use the table work area -- which is not allowed in ABAP-OOPS.
    I would really appreciate if anyone could show me some insight regarding this. Thank you.
    Kshitij R. Devre

    Hi Kshitij
    It would be really good if we could use both together. But as I know, it is not possible. "GET pernr." is an event-like loop statement and so cannot be used in OO context. And I guess, the same restriction holds for the "LDB_PROCESS" since it uses LDB-specific processing.
    What I suggest you is to use standard and BAPI functions.
    Sorry for giving bad news...
    *--Serdar

  • Free goods by a program

    How to create a sales order with free goods with an abap function?
    Now, I'm creating a sales order with  function 'SD_SALESDOCUMENT_CREATE' but don't know how to include free goods.
    I would like to use a manual condition type to introduce free goods with a program.
    Thanks in advance.

    check the following code, it may be useful
    SORT I_CR BY BUKRS  KNUMA VKORG VTWEG SPART.
    *Generate Cr. Memo request Sales area wise.
      LOOP AT I_CR.
    *Do not conider the record which net scheme amount is lessthan or equal
    *to zero
        IF I_CR-NSAMT > 0.
          L_ITEM = L_ITEM + 1.
          CLEAR IT_ORIT.
          IT_ORIT-ITM_NUMBER = L_ITEM.
          IT_ORIT-MATERIAL = I_CR-MATNR.
       IT_ORIT-BILL_BLOCK = ''.
          IT_ORIT-TARGET_QTY = '0'.
          IT_ORIT-MATL_GROUP = I_CR-MATKL.
          APPEND IT_ORIT.
          CLEAR IT_ITINX.
          IT_ITINX-ITM_NUMBER = 'X'.
          IT_ITINX-MATERIAL = 'X'.
       IT_ITINX-BILL_BLOCK = 'X'.
          IT_ITINX-TARGET_QTY = 'X'.
          IT_ITINX-MATL_GROUP = 'X'.
          APPEND IT_ITINX.
          CLEAR IT_ORPT.
          IT_ORPT-PARTN_ROLE = 'AG'.
          IT_ORPT-PARTN_NUMB = I_CR-KUNAG.
          APPEND IT_ORPT.
         CLEAR L_VAL.
         L_VAL = I_CR-MG_NSAMT.
         L_FK = I_CR-FKIMG.
         DIVIDE I_CR-FKIMG BY I_CR-MG_FKIMG.
         L_VAL = L_VAL * I_CR-FKIMG.
         DIVIDE L_VAL BY L_FK.
         CLEAR L_FK.
          IT_COND-ITM_NUMBER = L_ITEM.
          IT_COND-COND_TYPE = 'ZBLD'.
          IT_COND-COND_VALUE = I_CR-NSAMT.
          IT_COND-CURRENCY = 'INR'.
          APPEND IT_COND.
          IT_CONDX-ITM_NUMBER = L_ITEM.
          IT_CONDX-COND_TYPE = 'ZBLD'.
          IT_CONDX-UPDATEFLAG = 'U'.
          IT_CONDX-COND_VALUE = 'X'.
          IT_CONDX-CURRENCY = 'X'.
          APPEND IT_CONDX.
          AT END OF SPART.
            L_FLAG = 'X'.
          ENDAT.
          IF L_FLAG = 'X'.
            IT_HEADER-REFOBJTYPE = 'BUS2094'.
            IT_HEADER-DOC_TYPE = 'ZCMR'.
            IT_HEADER-SALES_ORG = I_CR-VKORG.
            IT_HEADER-DISTR_CHAN = I_CR-VTWEG.
            IT_HEADER-DIVISION = I_CR-SPART.
            IT_HEADER-ORD_REASON = 'Z15'.
            IT_HEADER-BILL_BLOCK = ' '.
           IT_HEADER-TELEPHONE  = 'AUTO'.
            IT_HEADX-DOC_TYPE = 'X'.
            IT_HEADX-SALES_ORG = 'X'.
            IT_HEADX-DISTR_CHAN = 'X'.
            IT_HEADX-DIVISION = 'X'.
            IT_HEADX-ORD_REASON = 'X'.
            IT_HEADX-UPDATEFLAG = 'I'.
            IT_HEADX-BILL_BLOCK = 'X'.
           IT_HEADX-TELEPHONE = 'X'.
            PERFORM SUB_CALL_BAPI.
            REFRESH : IT_HEADER, IT_ORIT, IT_ORPT, IT_ITINX,
                      IT_COND, IT_CONDX.
            CLEAR : IT_HEADER, IT_ORIT, IT_ORPT, IT_ITINX,
                    L_VKORG, L_VTWEG, L_SPART, L_FLAG, L_ITEM,
                    IT_COND, IT_CONDX,L_FLAG.
          ENDIF.
        ENDIF.
      ENDLOOP.
    *&      Form  SUB_CALL_BAPI
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_CALL_BAPI .
      DATA: L_ERR(1),
            L_VBELN LIKE ZSD_RBT_ELG_INV-VBELN,
            L_FLAG1(1),
            L_ERR1(1),
            L_FLAG2(1),
            L_ERR2(1),
            L_VAL1 LIKE ZSD_RBT_ELG_INV-NETWR.
      DATA: ARKTX(15) TYPE C VALUE 'VBRP-ARKTX(&1)'.
      DATA: C(2) VALUE '&1'.
      DATA: COUNTER(2) TYPE N.
    SET UPDATE TASK LOCAL.
      REFRESH: IT_RET.
      CLEAR: L_ERR, L_VBELN, L_VAL1, L_FLAG1.
      CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
        EXPORTING
      SALESDOCUMENT                 =
         SALES_HEADER_IN               = IT_HEADER
         SALES_HEADER_INX              = IT_HEADX
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       = ' '
      INT_NUMBER_ASSIGNMENT         = ' '
      BEHAVE_WHEN_ERROR             = ' '
      LOGIC_SWITCH                  = ' '
      BUSINESS_OBJECT               = ' '
      TESTRUN                       =
      CONVERT_PARVW_AUART           = ' '
      STATUS_BUFFER_REFRESH         = 'X'
       IMPORTING
         SALESDOCUMENT_EX              = L_VBELN
      SALES_HEADER_OUT              =
      SALES_HEADER_STATUS           =
       TABLES
         RETURN                        = IT_RET
         SALES_ITEMS_IN                = IT_ORIT
         SALES_ITEMS_INX               = IT_ITINX
         SALES_PARTNERS                = IT_ORPT
      SALES_SCHEDULES_IN            =
      SALES_SCHEDULES_INX           =
         SALES_CONDITIONS_IN           = IT_COND
         SALES_CONDITIONS_INX          = IT_CONDX
      SALES_CFGS_REF                =
      SALES_CFGS_INST               =
      SALES_CFGS_PART_OF            =
      SALES_CFGS_VALUE              =
      SALES_CFGS_BLOB               =
      SALES_CFGS_VK                 =
      SALES_CFGS_REFINST            =
      SALES_CCARD                   =
      SALES_TEXT                    =
      SALES_KEYS                    =
      SALES_CONTRACT_IN             =
      SALES_CONTRACT_INX            =
      EXTENSIONIN                   =
      PARTNERADDRESSES              =
      SALES_SCHED_CONF_IN           =
      ITEMS_EX                      =
      SCHEDULE_EX                   =
      BUSINESS_EX                   =
      INCOMPLETE_LOG                =
      EXTENSIONEX                   =
      CONDITIONS_EX                 =
      PARTNERS_EX                   =
      TEXTHEADERS_EX                =
      TEXTLINES_EX                  =
      BATCH_CHARC                   =
      CLEAR L_ERR.
      LOOP AT IT_RET.
        IF IT_RET-TYPE EQ 'E'.
          LEAVE TO LIST-PROCESSING.
          WRITE:/ 'BAPI ERROR', IT_RET-MESSAGE.
          L_ERR = 'X'.
        ELSEIF IT_RET-TYPE = 'S'
               AND IT_RET-ID = 'V1'.
          LEAVE TO LIST-PROCESSING.
          WRITE:/ IT_RET-MESSAGE.
        ENDIF.
      ENDLOOP.
      IF L_ERR IS INITIAL.
        CLEAR L_ERR.
        COMMIT WORK.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          =
    IMPORTING
       RETURN        =

  • Overloaded methods-yes or no & is this a good practice

    say i have two methods with the same name that take in the same parameters and have the same return type. the difference between the two is that one is static while the other is not. Also the methods contain different codes.
    are the methods going to function normally when i use em? also if they do function normally, is this essentially a good practice?
    if code is needed to answer this, please do mention it and i will think of a mini scenario where this can be applied and write a small piece of code for that.
    thanx. help will be appreciated.

    avi.cool wrote:
    duffymo wrote:
    each account has its own password that the user sets when the account is created-this password is declared as a state variable in the class file. One password per account? A bad model, IMO. My on-line banking software associates credentials with me, not my accounts. I see several accounts when I log in, and I don't have to log in individually for each one.
    besides that, theres also a bank password-this is declared and initialized as a static state variable in the class file. some of the operations require the bank password for access while others require account password.Static bank password? I'm very glad this is a throw-away student exercise, because you have no idea what you're doing.hahaaa, tru tru, its for a skool assignment for my first ever programming course. though not a throw away, i putting a lot of work into this :-) i m not actually trying to resolve any security issues here or strengthen account security. basically, I am only trying to exhibit a tiny bit of creativity while showing understanding of course contents. so nothing to stress on :-D i know not very creative but its all i got at this stage.
    i was trying to exhibit the use of overloaded methods in my program by having method to check the password that the user enters to access operations.
    now the ones that require account password, i was thinking of having the password check method as a non-static method since its associated with the object.
    while the ones that need bank password, i wanted to have as static method.
    i wanted both methods to have the same name.You've no idea what you're doing.
    how i solved it,
    i decided on having both methods as static methods. the one that checks account password, takes in two parameters, the account name(object name) and the string to be checkd. the one that checks bank password, takes in only one parameter- the string to be checked.Wrong.i would be really thankful if you could help me rectify my mistake and advice on how i should be doing this. is there a conceptual error? i am a bit confused now.
    Its exactly what I told you.. but now, you just have to come on here and post this :p
    and isn't this sort of like cheating? :P I mean this IS our exam you know... You're basically asking other for the arithmetic and logic lol.

  • Good practices for ECC 6.0 wr.t. internal tables..

    hi,
    i am told that when defining internal tables in ecc 6.0, we shud avoid using OCCURS and WITH HEADER LINE.  and always use work areas..
    is this right ? is this a good practice or a must ?
    i followed this and created an internal table without a header line .then i  am using a collect statement in my programn which fails and says that IT is not with header line !!
    COLLECT ITT.
    what to do ?
    thks

    Yes, that is correct.  SAP is pushing the use of ABAP Objects and you can not use OCCURS or HEADER LINEs in the ABAP OO context.  You should always defined explicitly and a work area.
    Data: itab type table of mara.
    Data: wa like line of itab.
    So then you must keep this in mind when doing any operations on internal tables, like in the case of the COLLECT statement, the syntax would be.
    wa-field1 = '1'.
    wa-field2 = '2'.
    Collect wa into itab.
    Regards,
    Rich Heilman

  • Regarding good practice

    Hi,
    Can somebody let me know whether it is a good practice to have two declare section in same procedure in pl/sql programming. Is there any draw back for same?
    Regards,
    basil Abraham.

    user575682 wrote:
    Can somebody let me know whether it is a good practice to have two declare section in same procedure in pl/sql programming. Is there any draw back for same? It is good practice not to have declare sections at all - as PL/SQL code is best done inside the Oracle database as stored packages and procedure and functions. This does not require a declare section at all - unless when dealing with the exception of dynamic PL code. (an exception that requires very sound technical reasoning)
    For the external applications making PL/SQL calls using anonymous PL/SQL code blocks, these may use declare sections.. but usually not. Why?
    Declarations are typical for variables to be used in the anonymous block. As bind variables should be used by the application, there is very seldom the need to make use of a declare section.
    So the declare section is not something that you should often see and use in production PL/SQL code. Both in stored code in the database, and in anonymous block code in external applications.
    Mostly the declare section is found in code (anonymous PL/SQL blocks) used for purposes like testing. (e.g. typically adhoc code and not formal production code)

  • Are there any good DVD authoring programs for Mac now that Apple has discontinued DVD Studio and iDVD? I need to make DVDs that have interactive menus and such (Final Cut X and Compressor 4's DVD option is a little cheap). Any ideas?

    Are there any good DVD authoring programs for Mac now that Apple has discontinued DVD Studio and iDVD? I need to make DVDs that have interactive menus and such (Final Cut X and Compressor 4's DVD option is a little cheap and doesn't provide any kind of professional DVD authoring). Any ideas?

    This comes up a lot these days.
    Practically speaking, there are really four options for the Mac platform: Toast (<$100),  Adobe Premier Productiom ($1,600 to buy or $50/month to rent),  find a copy of Final Cut Studio from 3rd  party (+/- $1,000 new) or a boxed edition of iLife to get iDVD ($50 - $90 on Amazon new).
    The other question everyone has is how many OS versions before iDVD or FCS breaks? No one knows, but Apple has said they're no longer supporting these legacy apps. Of course, no one is mandated to upgrade to a new OS unless they buy a new computer. So if it works on a system, stay with it as long as it makes sense.
    Good luck.
    Russ

  • Is it good practice to define text elements in User exits & there by using?

    Hi Experts,
    Simple doubt that, am wrting code in a User Exit. So, here my code works only, if the DOC TYPE = 'XXX'.
    So, instead of using hard coding as 'XXX', I wuld like to use a text element, like
    if DOC TYPE = text-xxx.
    my logic.
    endif.
    and creating the same text element.
    so, let me know that,
    Is it safe/recommended to use text-element in exits?
    Is it good practice to define text elements in User exits?
    thanq

    u can also use SET ID's if u dont want to hardcode like that in ur program.
    if u use SET ids , no need of transport request in case of change in the DOC types , directly u can change values in that set it , its like a master id.
    sytax will be like this
    doc_type in g_doc_type(this is set id ).
    for creation of set ids see tcode GS01.
    regards
    Prabhu

  • Is VHDX for data drive considered good practice on a client PC?

    Hi!
    I don't like putting user's data files (documents, etc.) inside the user's Documents directory on C:. Instead I prefer having them on a D: disk, separate from the OS. On the other hand I don't want to create a fixed size partition as I consider it a waste
    of space, especially when everything is on a rather small SSD.
    Therefore, I consider creating a virtual hard disk (VHDX) on my C: drive and making it dynamically expanding. This would allow me to store data on that "separate" disk which is actually an expanding VHDX file on C:. One problem is that for some
    unknown reason Windows 8.1 is not able to auto-attach such disks on startup, but I have seen some workarounds to auto-mount them through tasks.
    My question is the following: Is it considered good practice to put all data files on such a dynamic VHDX instead on a separate partition? Reading the VHDX explanations it looks like this file format is very stable (even in case of power loss) and is widely
    used in virtual servers. Performance should be also very good. Therefore I don't see any reason to not use it for my data drive. Or are there any drawbacks?
    Thanks in advance for any help.
    Best regards,
    Anguel

    Hi,
    Since the VHDX is created on C which should be the system partition, I don’t think it is more safety than separate partition.
    Please consider that once the system corrupted and we have to format the C to reinstall the System, it may be difficult for us to recovery the date. But the separated partition will be easily stayed without changes.
    You can try to shrink the C volume in Disk management to create a new partition.
    Just my thought.  
    Kate Li
    TechNet Community Support

  • What is a good practice to handle LOV in jdev apps?

    Hi, experts,
    In jdev 11.1.2.3,
    In our projects, there are many LOVs which the value are stored in a common dictionary table, for example in table refcode:
    refcode(id, low_value,high_value,meaning,domain_no),
    Different LOVs will retrieve value pairs(low_value,meaning) , or (high_value,meaning) from refcode table by using domain_no as the filtering criteria.
    In the end user's UI, the code/number field values should be displayed by a meaning word from refcode,
    To accomplish this goal, I will create numberous associations between different tables with refcode,
    and create VOs to have refcode entity view as a secondary entity view.
    I feel some odd in doing so(because so many associations with the same refcode table),
    Is that a good practice to handle LOV this way ?
    Thanks.

    On Fusion Developer's Guide for Oracle Application Development Framework
    10.3 Defining a Base View Object for Use with Lookup Tables
    (http://docs.oracle.com/cd/E37975_01/web.111240/e16182/bclookups.htm#BABIBHIJ)
    10.3.3 How to Define the WHERE Clause of the Lookup View Object Using View Criteria
    There are valuable information and suggestions on implement lookup features, especially by using view criteria
    (the View Criteria and View accessor is one of important and great idea in ADF)
    I think, by using of view criteria, the derivative attribute to display fk information can be implemented in a convinent way without FK associations definition.

  • JTable: RFC on good practice (SQL queries from cell editor)

    I usually add/remove/edit JTable data from an external panel. But in this scenario, my client would like to be able to click on the first column of an empty row and enter a product number. Within the cell editor, I must make an SQL query to the database in order to determine if the product number is valid and if so, use part of the SQL data to populate other cells of the current row (like product description).
    My problem is that this just doesn't seem right! Isn't the cell editor executed on the only Swing thread? Also, if the product number is not valid, I correctly implement the stopCellEditing() method but for some reason, you can still navigate the table (click on any other cell or press the TAB key, etc)... weird!!
    Does anyone have a good practice on how to perform the SQL query in a better place and force a cell to be selected until you enter a valid number or press the CANCEL key?
    I was looking at implementing the TableModelListener's tableChanged(...) method but I'm not sure if that would be a better place either.
    I personally would edit outside of the table, but good practice seems hard when the requirement is to edit from a cell editor!!
    Any suggestion would be greatly appreciated!
    Thanks!

    maybe you could write an input verifier for the column that does the query and rejects invalid entries.
    maybe you could send the query off in a worker thread.
    as far as making the table so you can't select any cells, hmm. not sure.
    you could disable
    .setEnabled(false);the table until the query comes back, something like that.

  • Is that a good practice to use syncronize methods for application scope cls

    Is that a good practice to use synchronize method in a application scope class, so I have a doubt, there a is class A, it has application scope and it contains a synchronized method add, so because of some network traffic or any unexpected exception client1 got stuck in the method, will that add method available for any other client...?
    Edited by: navaneeth.j on Dec 17, 2009 4:02 AM
    Edited by: navaneeth.j on Dec 17, 2009 4:04 AM

    If it needs synchronization, then it probably doesn't belong in the application scope. Either keep it as is, or reconsider the scope, or make it static.

  • What is good practice for playing multiple video's in a single swf?

    Hello,
    I have build in the past a video wall with video's inside. After building this i came across some problems.
    If you have too many video players loading at once it takes a lot of processing and the tweens in the
    page while loading the video's where not moving fluidly, but more in a stuttering way.
    After lot's of test i found a good working solution.  I imported the flv video's into flash en exported them on the timeline
    as a embedded swf.  Then i externally loaded these swf files and that performed much better.
    Is it even good practice to load multiple video instances at once? I used this time the LoaderMax of greensock but the video's
    only play after it's completely loaded. I would like to find a way to progressive play all video's at.
    Does someone has experience with this?
    Regards,
    Chris.

    How about an XML file which supplies the title for each movie and the location or source of the video to be played?  Simple version below.
    <?xml version="1.0" ?>
    - <playlist>
    <video src="Gfx/video/Alex1.f4v" title="John Deere 330" />
    <video src="Gfx/video/Benni1.f4v" title="Hitachi Z240F" />
    <video src="Gfx/video/Scotti1.f4v" title="Hitachi Z350F" />
    <video src="Gfx/video/Scotti2.f4v" title="Hitachi Z350F" />
    </playlist>
    JR

  • Is it good practice to auto submit forms?

    My users use forms that involve lots of textual matter and sometimes when after working for hours typing into the forms they might move out to some other links there by not submitting the form.
    Is it a good practice to auto save the contents of the form if there has been no inactivity for 5 minutes?
    What are the pros and cons of this approach?
    One problem the above approach could throw is if the user actually types in some data and forgets to close the browser window, the forms keeps on getting submitting unintentionally. This is ok with the user.
    Other alternatives like prompting the user for saving at frequent intervals have been thought of.

    as long as you can determine there's been no activity (simple enough with onblur/onfocus and other events in the fields) and can save the contents in a way that is not a submission, then it's not a bad idea. I wouldn't save after X minutes while the user is doing some entry, cuz it may interrupt what they are doing. Or you could use hidden frames and JS to save things without affecting the user.

Maybe you are looking for

  • Smart quotes won't work

    Hello there dear community, for some reason, Pages will not put quotation marks as I want them to be. As I am from Germany and therefore gernerally write in German, quotation marks are not " " but „ " . I have not figured out how to get Pages to do t

  • Firefox no longer works for many Banks

    The whole point of Firefox was that it was customizable. Now it doesn't work. It doesn't even work on your own pages. I may as well use AppleSafari or switch to Chrome or Opera. I hate having to waste my time customizing Chrome, but will seriously co

  • Why is the content missing from my messages in the Mail app?

    Yesterday, because my email addresses are changing, I modified the settings to my accounts in the email application Mail so that they properly connect to the new email addresses and settings. Most of the accounts are working fine. However, in one of

  • Set default value to UTC DateTime?

    Hi; Is there a way to set a default value to be the current UTC date & time? And if so, how do I put that in a SQL script? (I have given up on using the Migration Workbench and am hand writing my sql script. I looked at all the forums and this seems

  • Is there adobe flash foe the iPad

    I need adobe flash on my IPad. As I am finding out it is not possible to install it.  Is there something else I can download that will work the same?? Or is there a way to download it?