Using BAPI's in ABAP code

Hi bapi Guru's,
I am asked to use bapi's(Instead of BDC's) for data upload .I am not getting good documentation on 'USING BAPI's IN ABAP',Like Defining structures, and what are the FM's to be called like bapi_commit.
Any Info is Appriciated.
Regards
satish

Sorry Satish,
Maybe this is going off topic a little, bit perhaps also its relevant as you have been asked to move from BDC's to BAPIs.
Juan,
When I talk about debugging, there are two levels to this:
<b>1. Debugging by the programmer</b>
In this case, how can it be easier to debug an error from a BAPI than from the screen?  For a sales order, for example, when you enter a delivery date of 01.01.2000 for an item, via BDC you will get an error message as the item is entered (something along the lines of delivery date is in the past), and you will see exactly the date you have entered, and if you don't understand the error, you can click on F1 and it will give you the long description of the error.  Via a BAPI, you would get the error message, and you MIGHT get the item number and the date in question.  But if you don't understand the error what do you do then?  Debug the BAPI itself?  You could, but isn't this a rather lengthy way to get to the root of the problem?  In general, any errors you get calling BAPIs/BDCs are errors with your master data, or breaking business rules, you shouldn't have to debug standard code to tell you whats going wrong, the application can tell you.
<b>2. Debugging by the end user</b>
When you implement a BAPI/BDC this will be related to an interface/automated transaction etc.  When its in production you will occassionally get errors (due to bad master data, not fully capturing all the business logic in your custom coding [it happens], technical issues etc.)  What do you do then?  In the case of BDC you can do nothing.  The error is recorded, and you can get end users to process the errors by stepping through the screens (which they already know how to use) and make corrections as required.  In the case of BAPIs, you have to record the error in a table or a file, then develop some kind of interface to display the errors, then develop some kind of process for re-processing the errors.  If the data used to call the BAPI is not correct then you also need to provide a facility for changing the data before reprocessing.  Normally you do none of this because its too much work and you end up having all errors coming back to the SAP team who have to debug and change table entries etc. to get it all to work.  I would not say that this makes BAPIs easier to debug.
Oops, just realised my pasta is burning!!!
Anyway, think I got my point across.  Not personal but feel quite strongly about this topic.  To me BDC's are still a relevant tool despite the push for Idocs/BAPIs.
Cheers,
Brad

Similar Messages

  • Can I use OLAP variable in ABAP Code of infoobject filter

    I have 0FISCPER infoobject in filter section of info-package while loading data.
    Below OLAP varaibles has below dynamic values that are being calculated at run time.
    0P_PRFP2 -  (Current fiscal period - 2)   ex: 2010010
    0P_PRFP1 -  (Current fiscal period - 1)   ex: 2010011
    0FPER    -    (Current fiscal period )        ex: 2010012
    I want to write ABAP CODE FOR using filter values from 0P_PRFP2 to 0FPER. (Last 3 fiscal periods - ex: 2010010 to 2010012).
    how to  use above standard OLAP variables in ABAP CODE to assign l_t_range (low or  high).

    try this using ABAP routine option (6)
    DATA: curryear(4)           type N,
                 currperiod(2)         type N,
                 prevper1(2)           type N,
                 prevyear1(4)         type N,
                 prevper2(2)           type N,
                 prevyear2(4)         type N,
                 prevfiscperYr1(7)   type N,
                 prevfiscperYr2(7)   type N,
                 prevfiscper1(3)      type N,
                 prevfiscper2(3)      type N,
                 w_length1              type i,
                 w_length2              type i.
      curryear = SY-DATUM+0(4).
      currperiod = SY-DATUM+4(2).
      If currperiod EQ '01'.
        prevyear1 = curryear - 1.
        prevper1   =  '12'.
        prevyear2 = curryear - 1.
        prevper2   = '11'.
      elseif currperiod EQ '02'.
        prevyear1 = curryear.
        prevper1   = '01'.
        prevyear2 = curryear - 1.
        prevper2   = '12'.
      else.
        prevyear1 = curryear.
        prevper1   =   currperiod - 1.
        prevyear2 = curryear.
        prevper2   = currperiod - 2.
      endif.
      w_length1 = STRLEN( prevper1 ).
      If w_length1 = 1.
        concatenate '0' prevper1 into prevper1.
      Endif.
      w_length2 = STRLEN( prevper1 ).
      If w_length2 = 1.
        concatenate '0' prevper2 into prevper2.
      Endif.
      concatenate '0' prevper1 into prevfiscper1.
      concatenate '0' prevper2 into prevfiscper2.
      concatenate prevyear1 prevfiscper1 into prevfiscperYr1.
      concatenate prevyear2 prevfiscper2 into prevfiscperYr2.
      l_t_range-low = prevfiscperYr2.
      l_t_range-high = prevfiscperYr1.
    *  modify l_t_range index l_idx from l_t_range.
    l_t_range-sign   = 'I'.
    l_t_range-option = 'BT'.
    modify l_t_range index l_idx.

  • Writing to BI on demand using http request in ABAP code

    Hi Gurus
    I am getting ICM_HTTP_CONNECTION_FAILED error when I execute a program which contains HTTPS request. The purpose of the program is to write in bi.demand.com. The HTTP error code is 400.
    Also in SMICM I get the following error:
    ERROR => NiBufIConnect: non-buffered connect pending after 5000ms (hdl 29;XX.XXXXX.com:443) [nibuf.cpp    4611]
    WARNING => Connection request from (25/133/3) to host: XX:XXXXXX.com, service: 443 failed (NIECONN_REFUSED)
    210 ACCLIMATION, acclimation-PC, 12:38:29, M3, W0, SE38, 6/2 [icxxconn_mt.c 2321]
    What should I do to correct this?
    Thanks in advance.
    Regards
    Sunny

    Hi Sunny,
    None of this looks familiar to me.  What is the url that you are trying to request?
    Are there potentially any proxy servers between your machines and the internet that need to be configured into your application?
    Cheers
    Steve

  • Refresh used component display by ABAP code in another used component

    Hi,
    I have a contract (WEB UI component 'IUCONH') which contains used components, among others: actions ('GSACTIONS') and attachments ('GS_CM'). I enhanced the GSACTIONS so that it changes  the content of contract attachments programatically (changing documents by use of BOL: status of documents, deleting...). However, although the backend content changes, the GS_CM UI component doesn't know that and doesn't change the list of the displayed documents till user refreshes the browser. If attachments' view is expanded for the first time after the action has been taken, then it displays correct content (obviously, due to 'lazy' initialization).
    I need to initiate frontend refresh of one used component from another (that is, the program within GSACTIONS should initiate refresh in GS_CM).
    How can I do this?
    Thanks in advance!
    KR,
    Igor

    Hi Igor,
    You can call publish_current( ) method on your context node at the place where you programmatically change the content to make them reflect directly. The syntax will be as follows:
    me->typed_context-><node_name>->collection_wrapper->publish_current( ).
    Replace <node_name> with the node where you change the data.
    Try this and check if it works.
    Regards,
    Shiromani

  • Data transfer using BAPI'S

    please get me the detailed procedure  ( including code) of any data transfer program using BAPI's

    check the sample code....it is used to transfer the data to MM01 tcode.
    *TO CREATE MATERIAL USING BAPI.
    STRUCTURE DECLARATIONS *
    TABLES: BAPIMATHEAD, "Headerdata
    BAPI_MARA, "Clientdata
    BAPI_MARAX, "Clientdatax
    BAPI_MARC, "Plantdata
    BAPI_MARCX, "Plantdatax
    BAPI_MAKT, "Material description
    BAPI_MBEW, "VALUATION DATA
    BAPI_MBEWX,
    BAPI_MARM,
    BAPI_MARMX,
    bapi_mean,
    BAPIRET2. "Return messages
    DATA:V_FILE TYPE STRING. "input data file
    DATA:
    BEGIN OF LSMW_MATERIAL_MASTER,
    MATNR(018) TYPE C, "Material number
    MTART(004) TYPE C, "Material type
    MBRSH(001) TYPE C, "Industry sector
    WERKS(004) TYPE C, "Plant
    MAKTX(040) TYPE C, "Material description
    DISMM(002) TYPE C, "Extra Field Added In the Program as itsrequired
    MEINS(003) TYPE C, "Base unit of measure
    MATKL(009) TYPE C, "Material group
    SPART(002) TYPE C, "Division
    LABOR(003) TYPE C, "Lab/office
    PRDHA(018) TYPE C, "Product hierarchy
    MSTAE(002) TYPE C, "X-plant matl status
    MTPOS_MARA(004) TYPE C, "Gen item cat group
    BRGEW(017) TYPE C, "Gross weight
    GEWEI(003) TYPE C, "Weight unit NTGEW(017) TYPE C, "Net weight
    GROES(032) TYPE C, "Size/Dimensions
    MAGRV(004) TYPE C, "Matl grp pack matls
    BISMT(018) TYPE C, "Old material number
    WRKST(048) TYPE C, "Basic material
    PROFL(003) TYPE C, "DG indicator profile
    KZUMW(001) TYPE C, "Environmentally rlvt
    BSTME(003) TYPE C, "Order unit
    VABME(001) TYPE C,
    EKGRP(003) TYPE C, "Purchasing group
    XCHPF(001) TYPE C, "Batch management
    EKWSL(004) TYPE C, "Purchasing key value
    WEBAZ(003) TYPE C, "GR processing time
    MFRPN(040) TYPE C, "Manufacturer part number
    MFRNR(010) TYPE C, "Manufacturer number
    VPRSV(001) TYPE C, "Price control indicator
    STPRS(015) TYPE C, "Standard price
    BWPRH(014) TYPE C, "Commercial price1
    BKLAS(004) TYPE C, "Valuation class
    bwkey(004) type c,
    END OF LSMW_MATERIAL_MASTER.
    INTERNAL TABLE DECLARATIONS *
    *to store the input data
    DATA:
    BEGIN OF it_matmaster OCCURS 0.
    INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
    DATA:
    END OF it_matmaster.
    *for material description
    DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
    INCLUDE STRUCTURE BAPI_MAKT .
    DATA:END OF IT_MATERIALDESC.
    *FOR gross wt
    data: begin of it_uom occurs 0.
    include structure BAPI_MARM.
    data:end of it_uom.
    DATA: BEGIN OF IT_UOMX OCCURS 0.
    INCLUDE STRUCTURE BAPI_MARMX.
    DATA:END OF IT_UOMX.
    data:begin of it_mean occurs 0.
    include structure bapi_mean.
    data:end of it_mean.
    DATA:BEGIN OF IT_MLTX OCCURS 0.
    INCLUDE STRUCTURE BAPI_MLTX.
    DATA:END OF IT_MLTX.
    *to return messages
    DATA:BEGIN OF IT_RETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA:END OF IT_RETURN.
    SELECTION SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
    PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1 .
    AT SELECTION SCREEN *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    PROGRAM_NAME = SYST-CPROG
    DYNPRO_NUMBER = SYST-DYNNR
    FIELD_NAME = 'P_FILE'
    IMPORTING
    FILE_NAME = P_FILE.
    TO UPLOAD THE DATA *
    START-OF-SELECTION.
    V_FILE = P_FILE.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = V_FILE
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = 'X'
    HEADER_LENGTH = 0
    READ_BY_LINE = 'X'
    DAT_MODE = ' '
    IMPORTING
    FILELENGTH =
    HEADER =
    tables
    data_tab = IT_MATMASTER
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_READ_ERROR = 2
    NO_BATCH = 3
    GUI_REFUSE_FILETRANSFER = 4
    INVALID_TYPE = 5
    NO_AUTHORITY = 6
    UNKNOWN_ERROR = 7
    BAD_DATA_FORMAT = 8
    HEADER_NOT_ALLOWED = 9
    SEPARATOR_NOT_ALLOWED = 10
    HEADER_TOO_LONG = 11
    UNKNOWN_DP_ERROR = 12
    ACCESS_DENIED = 13
    DP_OUT_OF_MEMORY = 14
    DISK_FULL = 15
    DP_TIMEOUT = 16
    OTHERS = 17
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ELSE.
    *DELETE IT_MATMASTER INDEX 1.
    ENDIF.
    DATA POPULATIONS *
    LOOP AT IT_MATMASTER.
    *HEADER DATA
    BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
    BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
    BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-Mtart.
    BAPIMATHEAD-BASIC_VIEW = 'X'.
    BAPIMATHEAD-PURCHASE_VIEW = 'X'.
    BAPIMATHEAD-ACCOUNT_VIEW = 'X'.
    *CLIENTDATA
    BAPI_MARA-MATL_GROUP = IT_MATMASTER-MATKL.
    BAPI_MARA-DIVISION = IT_MATMASTER-SPART.
    BAPI_MARA-DSN_OFFICE = IT_MATMASTER-LABOR.
    BAPI_MARA-PROD_HIER = IT_MATMASTER-PRDHA.
    BAPI_MARA-PUR_STATUS = IT_MATMASTER-MSTAE.
    BAPI_MARA-ITEM_CAT = IT_MATMASTER-MTPOS_MARA.
    BAPI_MARA-NET_WEIGHT = IT_MATMASTER-NTGEW.
    BAPI_MARA-PO_UNIT = 'KG'.
    BAPI_MARA-UNIT_OF_WT_ISO = 'KG'.
    BAPI_MARA-UNIT_OF_WT = 'KG'.
    BAPI_MARA-PACK_VO_UN = 'KG'.
    BAPI_MARA-BASE_UOM_ISO = 'KG'.
    bapi_mara-size_dim = it_matmaster-groes.
    BAPI_MARA-MAT_GRP_SM = IT_MATMASTER-MAGRV.
    BAPI_MARA-OLD_MAT_NO = IT_MATMASTER-BISMT.
    BAPI_MARA-BASE_UOM = IT_MATMASTER-MEINS.
    BAPI_MARA-BASIC_MATL = IT_MATMASTER-WRKST.
    BAPI_MARA-HAZMATPROF = IT_MATMASTER-PROFL.
    BAPI_MARA-ENVT_RLVT = IT_MATMASTER-KZUMW.
    BAPI_MARA-PO_UNIT = IT_MATMASTER-BSTME.
    BAPI_MARA-VAR_ORD_UN = IT_MATMASTER-VABME.
    BAPI_MARA-PUR_VALKEY = IT_MATMASTER-EKWSL.
    BAPI_MARA-MANU_MAT = IT_MATMASTER-MFRPN.
    BAPI_MARA-MFR_NO = IT_MATMASTER-MFRNR.
    BAPI_MARAX-MATL_GROUP = 'X'.
    BAPI_MARAX-DIVISION = 'X'.
    BAPI_MARAX-DSN_OFFICE = 'X'.
    BAPI_MARAX-PROD_HIER = 'X'.
    BAPI_MARAX-PUR_STATUS = 'X'.
    BAPI_MARAX-ITEM_CAT = 'X'.
    BAPI_MARAX-NET_WEIGHT = 'X'.
    BAPI_MARAX-UNIT_OF_WT = 'X'.
    BAPI_MARAX-UNIT_OF_WT_ISO = 'X'.
    bapi_maraX-size_dim = 'X'.
    BAPI_MARAX-MAT_GRP_SM = 'X'.
    BAPI_MARAX-OLD_MAT_NO = 'X'.
    BAPI_MARAX-BASE_UOM = 'X'.
    BAPI_MARAX-BASE_UOM_ISO = 'X'.
    BAPI_MARAX-BASIC_MATL = 'X'.
    BAPI_MARAX-MFR_NO = 'X'.
    BAPI_MARAX-HAZMATPROF = 'X'.
    BAPI_MARAX-ENVT_RLVT = 'X'.
    BAPI_MARAX-PO_UNIT = 'X'.
    BAPI_MARAX-PACK_VO_UN = 'X'.
    BAPI_MARAX-VAR_ORD_UN = 'X'.
    BAPI_MARAX-PUR_VALKEY = 'X'.
    BAPI_MARAX-MANU_MAT = 'X'.
    BAPI_MARAX-MFR_NO = 'X'.
    *PLANT DATA
    BAPI_MARC-PLANT = IT_MATMASTER-WERKS.
    BAPI_MARC-PUR_GROUP = IT_MATMASTER-EKGRP.
    BAPI_MARC-BATCH_MGMT = IT_MATMASTER-XCHPF.
    BAPI_MARC-GR_PR_TIME = IT_MATMASTER-WEBAZ.
    BAPI_MARCX-PLANT = IT_MATMASTER-WERKS.
    BAPI_MARCX-PUR_GROUP = 'X'.
    BAPI_MARCX-BATCH_MGMT = 'X'.
    BAPI_MARCX-GR_PR_TIME = 'X'.
    *VALUATION DATA
    BAPI_MBEW-PRICE_CTRL = IT_MATMASTER-VPRSV.
    BAPI_MBEW-STD_PRICE = IT_MATMASTER-STPRS.
    BAPI_MBEW-COMMPRICE1 = IT_MATMASTER-BWPRH.
    BAPI_MBEW-VAL_AREA = IT_MATMASTER-BWKEY.
    BAPI_MBEW-VAL_CLASS = IT_MATMASTER-BKLAS.
    BAPI_MBEWX-PRICE_CTRL = 'X'.
    BAPI_MBEWX-STD_PRICE = 'X'.
    BAPI_MBEWX-COMMPRICE1 = 'X'.
    BAPI_MBEWX-VAL_AREA = IT_MATMASTER-BWKEY.
    BAPI_MBEWX-VAL_CLASS = 'X'.
    IT_MATERIALDESC-LANGU = 'EN'.
    IT_MATERIALDESC-MATL_DESC = IT_MATMASTER-MAKTX.
    append IT_materialdesc.
    IT_UOM-GROSS_WT = IT_MATMASTER-BRGEW.
    IT_UOM-ALT_UNIT = 'KG'.
    IT_UOM-ALT_UNIT_ISO = 'KG'.
    IT_UOM-UNIT_OF_WT = IT_MATMASTER-GEWEI.
    APPEND IT_UOM.
    IT_UOMX-GROSS_WT = 'X'.
    IT_UOMX-ALT_UNIT = 'KG'.
    IT_UOMX-ALT_UNIT_ISO = 'KG'.
    IT_UOMX-UNIT_OF_WT = 'X'.
    APPEND IT_UOMX.
    it_mean-unit = 'KD3'.
    append it_mean.
    it_mltx-langu = 'E'.
    it_mltx-text_name = it_matmaster-matnr.
    APPEND IT_MLTX.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
    headdata = BAPIMATHEAD
    CLIENTDATA = BAPI_MARA
    CLIENTDATAX = BAPI_MARAx
    PLANTDATA = BAPI_MARc
    PLANTDATAX = BAPI_MARcx
    FORECASTPARAMETERS =
    FORECASTPARAMETERSX =
    PLANNINGDATA =
    PLANNINGDATAX =
    STORAGELOCATIONDATA =
    STORAGELOCATIONDATAX =
    VALUATIONDATA = BAPI_MBEW
    VALUATIONDATAX = BAPI_MBEWX
    WAREHOUSENUMBERDATA =
    WAREHOUSENUMBERDATAX =
    SALESDATA =
    SALESDATAX =
    STORAGETYPEDATA =
    STORAGETYPEDATAX =
    FLAG_ONLINE = ' '
    FLAG_CAD_CALL = ' '
    IMPORTING
    RETURN = IT_RETURN
    TABLES
    MATERIALDESCRIPTION = IT_MATERIALDESC
    UNITSOFMEASURE = IT_UOM
    UNITSOFMEASUREX = IT_UOMX
    INTERNATIONALARTNOS = it_mean
    MATERIALLONGTEXT = IT_MLTX
    TAXCLASSIFICATIONS =
    RETURNMESSAGES =
    PRTDATA =
    PRTDATAX =
    EXTENSIONIN =
    EXTENSIONINX =
    read table it_return with key TYPE = 'S'.
    if sy-subrc = 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT =
    IMPORTING
    RETURN =
    *else.
    *CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
    IMPORTING
    RETURN =
    endif.
    WRITE:/ IT_RETURN-TYPE,
    2 IT_RETURN-ID,
    22 IT_RETURN-NUMBER,
    25 IT_RETURN-MESSAGE.
    IT_RETURN-LOG_NO,
    IT_RETURN-LOG_MSG_NO,
    IT_RETURN-MESSAGE_V1,
    IT_RETURN-MESSAGE_V2,
    IT_RETURN-MESSAGE_V3,
    IT_RETURN-MESSAGE_V4,
    IT_RETURN-PARAMETER,
    IT_RETURN-ROW,
    IT_RETURN-FIELD,
    IT_RETURN-SYSTEM.
    ENDLOOP.[/code]
    Reward if useful.
    Dara.

  • Sample ABAP code for userexits, and calling bapi's

    Hi,
    Can someone please send me sample ABAP code
    1) to do extractor enhancement using user exit.
    2) ABAP program to call BAPI to read live cache order series data in SNP and write to Idocs through some ports.
    3) ABAP routine to generate file name (based on date/country)in the infopackage to upload flatfiles.
    Thank you very much in advance and appreciate any help.
    Regards
    Prasad

    hai ,
    check this code...
    *& Tables
    tables : tstc,     "SAP Transaction Codes
             tadir,    "Directory of Repository Objects
             modsapt,  "SAP Enhancements - Short Texts
             modact,   "Modifications
             trdir,    "System table TRDIR
             tfdir,    "Function Module
             enlfdir,  "Additional Attributes for Function Modules
             tstct.    "Transaction Code Texts
    *& Variables
    data : jtab like tadir occurs 0 with header line.
    data : field1(30).
    data : v_devclass like tadir-devclass.
    *& Selection Screen Parameters
    selection-screen begin of block a01 with frame title text-001.
    selection-screen skip.
    parameters : p_tcode like tstc-tcode obligatory.
    selection-screen skip.
    selection-screen end of block a01.
    *& Start of main program
    start-of-selection.
    Validate Transaction Code
      select single * from tstc
        where tcode eq p_tcode.
    Find Repository Objects for transaction code
      if sy-subrc eq 0.
        select single * from tadir
           where pgmid    = 'R3TR'
             and object   = 'PROG'
             and obj_name = tstc-pgmna.
        move : tadir-devclass to v_devclass.
        if sy-subrc ne 0.
          select single * from trdir
             where name = tstc-pgmna.
          if trdir-subc eq 'F'.
            select single * from tfdir
              where pname = tstc-pgmna.
            select single * from enlfdir
              where funcname = tfdir-funcname.
            select single * from tadir
              where pgmid    = 'R3TR'
                and object   = 'FUGR'
                and obj_name = enlfdir-area.
            move : tadir-devclass to v_devclass.
          endif.
        endif.
    Find SAP Modifactions
        select * from tadir
          into table jtab
          where pgmid    = 'R3TR'
            and object   = 'SMOD'
            and devclass = v_devclass.
        select single * from tstct
          where sprsl eq sy-langu
            and tcode eq p_tcode.
        format color col_positive intensified off.
        write:/(19) 'Transaction Code - ',
        20(20) p_tcode,
        45(50) tstct-ttext.
        skip.
        if not jtab[] is initial.
          write:/(95) sy-uline.
          format color col_heading intensified on.
          write:/1 sy-vline,
          2 'Exit Name',
          21 sy-vline ,
          22 'Description',
          95 sy-vline.
          write:/(95) sy-uline.
          loop at jtab.
            select single * from modsapt
            where sprsl = sy-langu and
            name = jtab-obj_name.
            format color col_normal intensified off.
            write:/1 sy-vline,
            2 jtab-obj_name hotspot on,
            21 sy-vline ,
            22 modsapt-modtext,
            95 sy-vline.
          endloop.
          write:/(95) sy-uline.
          describe table jtab.
          skip.
          format color col_total intensified on.
          write:/ 'No of Exits:' , sy-tfill.
        else.
          format color col_negative intensified on.
          write:/(95) 'No User Exit exists'.
        endif.
      else.
        format color col_negative intensified on.
        write:/(95) 'Transaction Code Does Not Exist'.
      endif.
    Take the user to SMOD for the Exit that was selected.
    at line-selection.
      get cursor field field1.
      check field1(4) eq 'JTAB'.
      set parameter id 'MON' field sy-lisel+1(10).
      call transaction 'SMOD' and skip first screen.

  • How to extract data from info cube into an internal table using ABAP code

    HI
    Can Anyone plz suggest me
    How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
    Thankx in advance
    regds
    AJAY

    HI Dinesh,
    Thankq for ur reply
    but i ahve already tried to use the function module.
    When I try to Use the function module RSDRI_INFOPOV_READ
    I get an information message "ERROR GENERATION TEST FRAME".
    can U plz tell me what could be the problem
    Bye
    AJAY

  • Creating a long text using ABAP code.. fm SAVE_TEXT

    When you create an order via IW31 one of the options is to click on the text button and create a long text. I am basically trying to mimic this action from within my ABAP code.
    The text id details are as follows:
    Text Name       500000015000046  which is (5000000 + order number)
    Language        EN
    Text ID            KOPF         Order header text
    Text Object      AUFK       Order text
    If i manually create the text within the transaction i am then able to view and update it via function modules READ_TEXT and SAVE_TEXT. But if the text has not already been created READ_TEXT obviously returns nothing as it does not exist and SAVE_TEXT does not seem to created it!
    Anyone know how i would go about creating this text using ABAP code?
    Hope this make a bit of sense
    Thanks in advance
    Mart

    I have implemented the code as i think it should be. See below, can any see what is wrong. If i add init_text it makes no difference and adding the commit_text just makes it hang
    DATA: IT_TEXTS type standard table of TLINE,
           wa_texts like line of it_texts,
           wa_txtheader type THEAD.
    wa_txtheader-TDID     = 'KOPF'.
    wa_txtheader-TDSPRAS  = 'EN'.
    wa_txtheader-TDNAME   = '500000015000056'.
    wa_txtheader-TDOBJECT = 'AUFK'.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
      wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
      wa_texts-tdformat = '*'.
    wa_texts-tdline = 'hello'.
    append wa_texts to it_texts.
    CALL FUNCTION 'SAVE_TEXT'
      EXPORTING
        CLIENT                = SY-MANDT
        HEADER                = wa_txtheader
        INSERT                = 'X'
       SAVEMODE_DIRECT       = ' '
       OWNER_SPECIFIED       = 'X'
      LOCAL_CAT             = ' '
    IMPORTING
      FUNCTION              =
      NEWHEADER             =
      TABLES
        LINES                 = IT_TEXTS
    EXCEPTIONS
       ID                    = 1
       LANGUAGE              = 2
       NAME                  = 3
       OBJECT                = 4
       OTHERS                = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Schedule a background job for a program using ABAP code.

    Hi,
    I have to write a program to schedule a background job for another program.
    Need your help to understand how we can achieve this functionality.Any example of an abap code would be of great help.
    Need it urgently.
    Thanks in advance.
    Sandeep.

    Hi Sandeep,
    Here is the demo program regarding the BDC For the background job.
    report zprprbdc1
           no standard page heading line-size 255.
    include bdcrecx1.
    parameters: dataset(132) lower case.
    ***    DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
    *   If it is nessesary to change the data section use the rules:
    *   1.) Each definition of a field exists of two lines
    *   2.) The first line shows exactly the comment
    *       '* data element: ' followed with the data element
    *       which describes the field.
    *       If you don't have a data element use the
    *       comment without a data element name
    *   3.) The second line shows the fieldname of the
    *       structure, the fieldname must consist of
    *       a fieldname and optional the character '_' and
    *       three numbers and the field length in brackets
    *   4.) Each field must be type C.
    *** Generated data section with specific formatting - DO NOT CHANGE  ***
    ***data: begin of itab occurs 0 ,
    ***       matnr(20) type c,
    ***       mbrsh(30) type c,
    ***       mtart(30) type c,
    ***       kzsel(20) type c,
    ***       maktx(40) type c,
    ***       meins(5) type c,
    ***       end of itab.
    data: begin of record occurs 0,
    * data element: MATNR
            matnr_001(018),
    * data element: MBRSH
            mbrsh_002(001),
    * data element: MTART
            mtart_003(004),
    * data element: XFELD
            kzsel_01_004(001),
    * data element: MAKTX
            maktx_005(040),
    * data element: MEINS
            meins_006(003),
    * data element: MTPOS_MARA
            mtpos_mara_007(004),
          end of record.
    *** End generated data section ***
    start-of-selection.
    *perform open_dataset using dataset.
    perform open_group.
    **do.
    **read dataset dataset into record.
    **if sy-subrc <> 0. exit. endif.
    call function 'GUI_UPLOAD'
      exporting
        filename                      = 'c:\jitu\bdc\10002.txt'
       filetype                      = 'ASC'
       has_field_separator           = 'x'
    *   HEADER_LENGTH                 = 0
    *   READ_BY_LINE                  = 'X'
    *   DAT_MODE                      = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   CHECK_BOM                     = ' '
    *   VIRUS_SCAN_PROFILE            =
    *   NO_AUTH_CHECK                 = ' '
    * IMPORTING
    *   FILELENGTH                    =
    *   HEADER                        =
      tables
        data_tab                      = record
    * EXCEPTIONS
    *   FILE_OPEN_ERROR               = 1
    *   FILE_READ_ERROR               = 2
    *   NO_BATCH                      = 3
    *   GUI_REFUSE_FILETRANSFER       = 4
    *   INVALID_TYPE                  = 5
    *   NO_AUTHORITY                  = 6
    *   UNKNOWN_ERROR                 = 7
    *   BAD_DATA_FORMAT               = 8
    *   HEADER_NOT_ALLOWED            = 9
    *   SEPARATOR_NOT_ALLOWED         = 10
    *   HEADER_TOO_LONG               = 11
    *   UNKNOWN_DP_ERROR              = 12
    *   ACCESS_DENIED                 = 13
    *   DP_OUT_OF_MEMORY              = 14
    *   DISK_FULL                     = 15
    *   DP_TIMEOUT                    = 16
    *   OTHERS                        = 17
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    loop at record .
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  record-matnr_001.
    perform bdc_field       using 'RMMG1-MBRSH'
                                  record-mbrsh_002.
    perform bdc_field       using 'RMMG1-MTART'
                                  record-mtart_003.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                                  record-kzsel_01_004.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  record-maktx_005.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-MEINS'.
    perform bdc_field       using 'MARA-MEINS'
                                  record-meins_006.
    perform bdc_field       using 'MARA-MTPOS_MARA'
                                  record-mtpos_mara_007.
    perform bdc_transaction using 'MM01'.
    **enddo.
    endloop.
    perform close_group.
    *perform close_dataset using dataset.
    &*****************Reward point if helpful************&

  • How to delete cube old request by using abap code?

    Dear experts,
    Here is one thing need your help:
    We have one cube need to delete the old request. This cube is loaded daily and only need to delete the request of that month.
    I know there is one "Delete Overlap Requet" type in the process chain, but my concern is: in our DTP filter, different day the selection will have different values, let's say A and B, and A and B are not even overlap at all.
    So my question is:
    1. Can I still use "Delete Overlap Request" to delete the old request?
    2. If so, I see it can be implemented by abap routine, can anyone give me some sample code? Like how to delete request only in this month. And how to delete request whose selection is equal to a specific value.
    Note: one of the source cube is real time cube so can not delete the request from infopackage.
    Any post will be appreciated and thank you all for your time in advance!
    Regards.
    Tim

    Here is the intial code when I choose "Request Selection through Routine", please help me on how to choose the specific request and delete them in this routine.
    program conversion_routine.
    Type pools used by conversion program
    Global code used by conversion rules
    $$ begin of global - insert your declaration only below this line  -
    TABLES: ...
    DATA:   ...
    $$ end of global - insert your declaration only before this line   -
        InfoCube        = ZPC_DEL_REQ_ZBPS_C01
    form compute_ZPC_DEL_REQ_ZBPS_C01
      tables l_t_request_to_delete structure rsreqdelstruc
      using l_request like rsreqdone-rnr
      changing p_subrc like sy-subrc.
    *Insert Source Code to decide if requests should be deleted.
    *All Requests in table l_t_request_to_delete will be deleted
    *from Infocube ZPC_DEL_REQ_ZBPS_C01.
    *Add new requests if you want to delete more (from this cube).
    *Remove requests you did not want to be deleted.
    $$ begin of routine - insert your code only below this line        -
         loop at l_t_request_to_delete.
         endloop.
         clear p_subrc.
    $$ end of routine - insert your code only before this line         -
    endform.

  • How to insert a new line item in VA01/VA02 by using ABAP code?

    Hi Gurus
    i have a very tough requirement. the customer wants to insert a free goods after an item has been populated in VA01/VA02 automatically according to some certain rules. the input material may be a main material of a sales BOM.
    for example. let's suppose there is a material A who has two sub-material B and C which is maintained in a sales BOM via CS01/CS02. when the material A has been input in the line item in VA01/VA02, its quantity input and after the ENTER key has been clicked, another material D may be displayed in a new line as a gift if the condition met.  the condition relates to customer/material/quanity and these information are stored in a Z-table.
    on the other hand, if the material A is only a single material(not a BOM), the gift(material D) will also be filled automatically if the condition met.
    i have already enhance the FM cs_bom_explosion to filfill the requirment for BOM materials. whereas it is very hard to find the enhanment point for the single material.
    so my question is where is the correct place for me to insert the ABAP code, which decides whether the gift should be given or not and furthermore inserts the new line item into XVBAP. i tried to use MV45AFZZ, whereas the data is always inconsistant if a new line has been inserted. it is very strange that there is no temperary internal table storing line item data input in the table controal of VA01/VA02. system reads the line item data , line by line, via a system kernal function call.
    any hints are welcome. thanks

    HI Stephen,
    I have the same prolem. I modified the 5 global tables, but I don't see the new line in the screen.
    Can you help me with some details?
    Thx!
    Mihaela

  • How to generate new perner number using Abap Code in pa0002. what is the fu

    how to generate new perner number using Abap Code in pa0002. what is the function Module used.

    hi
    define internal number ranges for ur implementation then when u run PA 40  do not input any employee number , system will generate the employee number automatically.
    Regards
    sameer

  • How to transfer data in change log table of dso to z-table using abap code

    Hi  can you please explain me how to transfer data in change log table of dso to z-table using abap code ,with out using Function module concept

    PROGRAM NAME:   ZBW_DELTA_TO_GSTAR                                 **
    report ZBW_DELTA_TO_GSTAR no standard page heading
                                     line-size 120
                                     line-count 75
                                     message-id ZBW_MSG_CLS.
    tables:   ZGIV_DLTA_EBV_BB,
              ZGIV_DLTA_EM2_BL,
              ZGIV_DLTA_EM2_BK.
    Selection Screen Definitions
    SELECTION-SCREEN: BEGIN OF BLOCK INNER WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN: SKIP 1.
    PARAMETERS:       EBVBB RADIOBUTTON GROUP ROLL,
                      EM2BL RADIOBUTTON GROUP ROLL,
                      EM2BK RADIOBUTTON GROUP ROLL.
    SELECTION-SCREEN: END OF BLOCK INNER.
    Data:  WS_UPDATE_FLAG  Type C,
           UCounter(9)      Type N,
           ICounter(9)      Type N.
    DATA:  T_ZGIV_DLTA_EBV_BB Type Standard Table of ZGIV_DLTA_EBV_BB,
           s_ZGIV_DLTA_EBV_BB LIKE line of T_ZGIV_DLTA_EBV_BB.
    DATA:  T_ZGIV_DLTA_EM2_BK Type Standard Table of ZGIV_DLTA_EM2_BK,
           s_ZGIV_DLTA_EM2_BK LIKE line of T_ZGIV_DLTA_EM2_BK.
    DATA:  T_ZGIV_DLTA_EM2_BL Type Standard Table of ZGIV_DLTA_EM2_BL,
           s_ZGIV_DLTA_EM2_BL LIKE line of T_ZGIV_DLTA_EM2_BL.
    Standard Internal Tables - Describe usage.
    data: begin of i_AEPSD_O0140 occurs 0.
            include structure /BIC/AEPSD_O0140.
    data: end of i_AEPSD_O0140.
    data: begin of i_AEPSD_O0240 occurs 0.
            include structure /BIC/AEPSD_O0240.
    data: end of i_AEPSD_O0240.
    data: begin of i_AEPSD_O0340 occurs 0.
            include structure /BIC/AEPSD_O0340.
    data: end of i_AEPSD_O0340.
    data: begin of i_GIV_DLTA_EBV_BB occurs 0.
            include structure ZGIV_DLTA_EBV_BB.
    data: end of i_GIV_DLTA_EBV_BB.
    data: begin of i_GIV_DLTA_EM2_BK occurs 0.
            include structure ZGIV_DLTA_EM2_BK.
    data: end of i_GIV_DLTA_EM2_BK.
    data: begin of i_GIV_DLTA_EM2_BL occurs 0.
            include structure ZGIV_DLTA_EM2_BL.
    data: end of i_GIV_DLTA_EM2_BL.
    Miscellaneous Program Variables and Constants.
    TOP-OF-PAGE
    top-of-page.
    START-OF-SELECTION
    start-of-selection.
      Clear: i_GIV_DLTA_EBV_BB,
             i_GIV_DLTA_EM2_BK,
             i_GIV_DLTA_EM2_BL,
             UCounter, ICounter.
      IF EBVBB = 'X'.
        PERFORM 100_EXTRACT_EBV_BB_DELTA_RECS.
      ELSEIF EM2BK = 'X'.
        PERFORM 100_EXTRACT_EM2_BK_DELTA_RECS.
      ELSE.
        PERFORM 100_EXTRACT_EM2_BL_DELTA_RECS.
      ENDIF.
    FORM 100_EXTRACT_EBV_BB_DELTA_RECS
    FORM 100_EXTRACT_EBV_BB_DELTA_RECS.
      Refresh:   i_AEPSD_O0140,
                 i_GIV_DLTA_EBV_BB.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EBV_BB .
      Select * From /BIC/AEPSD_O0140
        Into TABLE i_AEPSD_O0140.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0140.
          MOVE-CORRESPONDING i_AEPSD_O0140 TO s_ZGIV_DLTA_EBV_BB.
          MOVE SY-DATUM to s_ZGIV_DLTA_EBV_BB-create_dt.
          INSERT ZGIV_DLTA_EBV_BB FROM s_ZGIV_DLTA_EBV_BB.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EBV_BB FROM  s_ZGIV_DLTA_EBV_BB.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EBV_BB_DELTA_RECS
    FORM 100_EXTRACT_EM2_BK_DELTA_RECS
    FORM 100_EXTRACT_EM2_BK_DELTA_RECS.
    Refresh:   i_AEPSD_O0240,
               i_GIV_DLTA_EM2_BK.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EM2_BK .
      Select * From /BIC/AEPSD_O0240
        Into TABLE i_AEPSD_O0240.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0240.
          MOVE-CORRESPONDING i_AEPSD_O0240 TO s_ZGIV_DLTA_EM2_BK.
          MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BK-create_dt.
            INSERT ZGIV_DLTA_EM2_BK FROM s_ZGIV_DLTA_EM2_BK.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EM2_BK FROM  s_ZGIV_DLTA_EM2_BK.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EM2_BK_DELTA_RECS
    FORM 100_EXTRACT_EM2_BL_DELTA_RECS
    FORM 100_EXTRACT_EM2_BL_DELTA_RECS.
    Refresh:   i_AEPSD_O0340,
               i_GIV_DLTA_EM2_BL.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EM2_BL .
      Select * From /BIC/AEPSD_O0340
        Into TABLE i_AEPSD_O0340.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0340.
          MOVE-CORRESPONDING i_AEPSD_O0340 TO s_ZGIV_DLTA_EM2_BL.
          MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BL-create_dt.
            INSERT ZGIV_DLTA_EM2_BL FROM s_ZGIV_DLTA_EM2_BL.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EM2_BL FROM  s_ZGIV_DLTA_EM2_BL.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EM2_BL_DELTA_RECS
    END-OF-SELECTION
    end-of-selection.
      perform D1000_REPORT_DATA.
    D1000_REPORT_DATA
    form D1000_REPORT_DATA.
    *Display the title of the program
      write: /25 SY-TITLE.
      skip.
    Diaplay the details of the user and time
      write: /1 'Executed by', 15 SY-UNAME, 30 'Date',
      38 SY-DATUM, 53 'Time', 60 SY-UZEIT.
      skip 2.
      write: /  'Delta Records have been extracted  ',
             /   'Updates : ', UCounter,
             /   'Inserts : ', ICounter.
      skip.
      skip 3.
      write: /20 'End of the report'.
    endform.                                           "D1000_REPORT_DATA
    chgeck it out this also may hep you

  • ABAP code which will use function module during field mapping in LSMW

    Hi,
    During field mapping in LSMW, for one of the field called field, I want to use a function module 'QF05_RANDOM_INTEGER', which will generate random numbers and map that random number to that field.
    How do I write ABAP code which uses function module, during filed mapping for a particluar field in LSMW ?
    Please help...
    Regards,
    Tushar.

    Hi Tushar,
    You can write in FORM ROUTINE and LSMW.
    I hope you know how to write ABAP code at field level.
    If not ...
    Come to change mode->select the field->Rule->ABAP Code
    write a perform statement in ABAP code at field level.
    <b>PERFORM test</b> using val
                 changing valu.
    Go to Utilities(at menu)->switch layout-> extras ->select Layout->check Form routine-> it will display a FORM Routine... at bottom
    this is the place where you can write some code for
    <b> FORM test</b> using value
              changing value1
      FM call....
    .ENDFORM  
    Get the value1 returned and use for the Field population.
    Reward points if this Helps.
    Manish
    Message was edited by:
            Manish Kumar

  • ABAP code used in transaction SU01

    Hi all,
    Can anyone tell me that whether is there any method by which I can pass the user id and can know whether that user has the SAP_ALL profile or not.
    The above is done by using the transaction SU01,but I need the ABAP code that is being used in this transaction.
    Regards,
    Varun.

    YOu can query the table:
    UST04
    select single * from UST04 where BNAME = sy-uname
                                               and PROFILE = 'SAP_ALL'.
    if sy-subrc = 0.
    write:/ 'The User' sy-uname 'has SAP_ALL profile'.
    endif.
    Regards,
    Ravi

Maybe you are looking for

  • Is there a forName() for java.lang.reflect.Type?

    Is there an equivelant to Class.forName() for all types? For example:forName("java.util.List<java.lang.Sring>"); //or forName("int");Such a method would return a java.lang.reflect.Type, instead of return a java.lang.Class See also Field.getGenericTyp

  • PSE 9 does not come with Camera Raw 6.2?

    Photosho Elements 9 does not come with camera raw 6.2 , I downloaded the trial version which came with an outdated 6.1... the only version of 6.2 is for PSE8 and does not work with PSE9 how is this possible? How can they release a product with an out

  • IDM CC 6.7 Extension blocked after upgrading to FireFox 3.6.6

    Well everything was going fine till i upgraded to ver 3.6.6. After running two-three times,it says Firefox blocked IDM CC for your protection. And i really want that add on enabled as i use IDM as my download manager. Please hel me.

  • Resetting iPhone 4 to become an iPod without activation

    Hi, I upgraded to iPhone 5S and want to keep using my iPhone 4 as an iPod (just at home, using the Wifi). Currently, the old iPhone is working (as an iPod). However, to make it work a little faster, I want to reset the old iphone 4, but am afraid tha

  • Communication between SAP e-recruitment and 3rd party website

    Hi, We are implementing e-recruitment module and would like to know how to transport a recruitment advertisement created in SAP e-Recruitment to a job website. Should we use IDOC and XI? Or is there some other way of doing it? How does SAP e-Recruitm