Macro in ABAP Code

Dear All,
I am trying to debug a Macro in SAP standard Extractor. I am unable to understand the line in bold. following is the Macro code:
DEFINE sel.
    when &1.
      sort s_t_select by fieldnm.        
      do.
        fetch next cursor g_cursor into id.
        if sy-subrc eq 0.
<b>          import &2 from database &3(bw) id id.</b>   
      loop at &2.
            cond_select = true.
            loop at s_t_select.
"delete" entry if select-option does not fit
              assign component s_t_select-fieldnm of
                structure &2 to <fs_field>.
              if sy-subrc ne 0.
                log_write 'E'          "message type
                          'MCEX'       "message class
                          '022'        "message number
                          i_isource    "message variable 1
                          s_estruc.    "message variable 2
                raise error_passed_to_mess_handler.
              endif.
         move-corresponding s_t_select to cond_select_tab.
         append cond_select_tab.
         at end of fieldnm.
                if not <fs_field> in cond_select_tab.
                  cond_select = false.
                  refresh cond_select_tab.        
                  exit.
                endif.
               refresh cond_select_tab.           
              endat.                              
            endloop.
            if cond_select eq true.
              append &2 to e_t_data.
              add 1 to counter.
            endif.
          endloop.
          if s_maximum_size le counter.
            exit.
          endif.
        else.
          close cursor g_cursor.
          s_flg_no_more_data = true.
          exit.
        endif.
      enddo.
    END-OF-DEFINITION.
The call is as follow:
sel 'MC13VD0ITM' mc13vd0itm_tab  mc13vd0itmsetup.

Hi pooja,
1. import &2 from database &3(bw) id id.
  IMPORT
  (See F1 Help )
2. The macro line
   is importing
   from database cluster :
   internal table &2
   from cluster table &3
3. where &2 &3 are the parameters
   passed to the macro while calling.
regards,
amit m.

Similar Messages

  • How to translate an excel macro to ABAP code

    Hi Guys,
    My requirement is need to put the subtotaling option w.r.t divison when i download the file to an excel sheet via OLE.
    Iam able to get the records in the excel sheet but unable to write the macro in ABAP code.
    the macro which i recorded in Excel is
    Range("A1:C3").Select
    Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(3), _
    Replace:=True, PageBreaks:=False, SummaryBelowData:=True
    how do i convert this into ABAP code .Pls help. Thanks...
    the data might be like
    NAME DIVISION AMOUNT
    ABC IT 400
    DEF BPO 500
    HTG IT 400

    Hi,
    You can run an excel macro like this
    CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
    Call Method of h_excel 'WORKBOOKS' = h_mapl.
    set property of h_excel 'VISIBLE' = 0.
    Call Method of h_mapl 'OPEN'
    EXPORTING
    #1 = d_file.
    CALL METHOD OF H_EXCEL 'ActiveWorkbook' = h_book .
    CALL METHOD OF H_book 'Activesheet' = H_sheet .
    CALL METHOD OF h_excel 'RUN'
    EXPORTING
    #1 = ld_macro.
    Check the links below as well
    http://sample-code-abap.blogspot.com/2009/07/controlling-excel-using-ole-automation.html
    http://arthur_ong.tripod.com/xab017.htm

  • Run a macro with ABAP code

    Hi everybody,
    Could someone help me finding a way to run a macro of an excel sheet with an ABAP program.
    Explanation:
    - I launch an abap program that opened an excel sheet with that kind of code
    include ole2incl.
    DATA : w_excel   type ole2_object,
               w_books   type ole2_object,
               w_book    type ole2_object,
               w_sheets  type ole2_object,
               w_sheet   type ole2_object,
               w_cell    type ole2_object,
               w_rows    type ole2_object,
               w_font    type ole2_object.
    create object w_excel 'Excel.Application'.
    CALL METHOD OF W_EXCEL 'WORKBOOKS' = W_BOOKS.
    CALL METHOD OF W_SHEET 'CELLS' = W_CELL
           exporting #1 = row
                     #2 = column.
    CALL METHOD OF W_SHEET 'SAVEAS'.
    With my ABAP program:
    - i can open my excel template.
    - i can write and format data inside my excel sheet.
    - i can close and save my excel sheet.
    but i don't how to run the macro that exists in my excel template.
    Thank you in advance.

    Hi,
    Executing Excel Macro from SAP ABAP
    I am populating data in excel sheet using OLE. This excel document contains Macro.
    Is there any way I can start execution of Macro as soon as data is populated in Excel sheet.
    If you are using OLE to populate the Excel Sheet then, then yes you can run a macro.
      CALL METHOD OF OBJ_EX_APP 'Run'
           EXPORTING #1 = MACROSTR.
    Adding a Field Exit
    To add a field exit first find the data element that is linked to the screen field- the screen number and program
    Run program RSMODPRF. You will need to create two function modules one FIELD_EXIT_MEPO_VENDOR and
    FIELD_EXIT_MEPO_VENDOR_A
    FIELD_EXIT_MEPO_VENDOR should have code simply of input = ouput.
    FIELD_EXIT_MEPO_VENDOR_A should have the code for whatever the functionality is required
    Go back to RSMODPRF and run the program without parameters. Use the push buttons to assign the screen, 'A' and program. Use the drop down to activate the field list.
    This should now work, but there is no way of debugging. For further information look at OSS 29377
    program zzdirlist.
    for AIX this method also works.
    DATA: BEGIN OF TABL OCCURS 0,
          TEXT(80) TYPE C,
          END OF TABL.
    DATA: COMMAND(256) TYPE C.
    COMMAND = 'ls'.
    CALL FUNCTION 'RFC_REMOTE_PIPE' DESTINATION 'SERVER_EXEC'
    EXPORTING COMMAND = COMMAND
    READ = 'X'
    TABLES PIPEDATA = TABL.
    LOOP AT TABL.
       WRITE:/ TABL-text.
    ENDLOOP.
    Open the following link,
    http://www.sap-img.com/abap/questions-about-bar-code-printing-in-sap.htm
    Regards,
    Jagadish.

  • Error : in  placement of Macro with ABAP code

    Hi,
    I have to replace the Macro rp-provide-from-last for 0105 infotype with subtype 05 and pn-begda ,pn-endda.please send me the code.
    thanks in advance.
    bye
    raj.

    Write as :
    sort p0105 by pernr SUBTY begda descending.
    loop at P0105 where SUBTY = '05'
                         and    endda >= pn-begda
                         and    begda <= pn-endda.
       i_p0105 = p0105. <----
    endloop.

  • Translating an excel macro to ABAP

    Hi Guys,
      My requirement is need to put the subtotaling option w.r.t divison when i download the file to an excel sheet via OLE.
    Iam able to get the records in the excel sheet but unable to write the macro in ABAP code.
    the macro which i recorded in Excel is
    Range("A1:C3").Select
        Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(3), _
            Replace:=True, PageBreaks:=False, SummaryBelowData:=True
    how do i convert this into ABAP code .Pls help. Thanks...
    the data might be like
    NAME  DIVISION   AMOUNT
    ABC     IT              400
    DEF      BPO         500
    HTG     IT              400

    Hi,
    You can run an excel macro like this
    CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
    Call Method of h_excel 'WORKBOOKS' = h_mapl.
    set property of h_excel 'VISIBLE' = 0.
    Call Method of h_mapl 'OPEN'
    EXPORTING
    #1 = d_file.
    CALL METHOD OF H_EXCEL 'ActiveWorkbook' = h_book .
    CALL METHOD OF H_book 'Activesheet' = H_sheet .
    CALL METHOD OF h_excel 'RUN'
    EXPORTING
    #1 = ld_macro.
    Check the links below as well
    http://sample-code-abap.blogspot.com/2009/07/controlling-excel-using-ole-automation.html
    http://arthur_ong.tripod.com/xab017.htm

  • Use of macros in abap- HR

    Hi Gurus,
           What is the exact use of macros in abap-hr.Because in normal abap also these macros are existing , but we will not use these in normal abap programming.So is there any specific reason for using macros in ABAP-HR.
    Thanks in advance..
    Regards,
    Rakesh.

    This is similar to Logical Database usage. We use LDBs in HR more than in other module. SAP has created many macros that can be used in HR. Ex: you have some macros to make use of when using PNP LDB in your program. Similarly SAP provided macros to read text from PCL1 cluster table. Same thing with reading payroll results. In addition you also can define your own macros in the program and use them in the code.

  • ABAP Code Required to remove #

    Hi,
    I have 2 characteristics 0COORDER and 0WBS_ELEMT value for which do not exist for all the data records. As a result I get # in the report. How do I replace # in the report with blank? I don’t want to use the VB Script, need a permanent fix. Where should I write ABAP routine for that and also please can anyone give me the ABAP code too.
    Thank you,
    sam

    in bex, you can use vba macro. in web, use table interface
    replacing '#'-sign for 'not assigned' in queries
    SAPBEXonRefresh()
    Dim c as range
    For Each c in resultArea.cells
    if c.Value = "#" then c.Value = "-"
    Next c
    or
    by Jens (consider to performance)
    put in SAPBEXonRefresh()
    resultArea.Select
    Cells.Replace What:="#", Replacement:=" ", LookAt:=xlPart, _
    SearchOrder:=xlByRows,
    MatchCase:=False,
    SearchFormat:=False, _
    ReplaceFormat:=False
    table interface, redefine CHARACTERISTIC_CELL method...
    if I_CHAVL = '#'.
    c_cell_content = ' '.
    endif.
    Hope it helps.
    Regards

  • Translate Excel Macro to Abap

    Hi all,
    I have the following macro recorded in my excel and want to 'translate' it to abap.
    The problem is that though it does not give any error and not sy-subrc <> 0 don't works well.
    When I select the cells to which I have put a name,  this name does not appear, if I execute the macro from the excel yes it works well.
    This is the macro;
    ActiveWorkbook.Names.Add Name:="nums", RefersToR1C1:="=Hoja1!R3C1:R8C1"
    Though also it works this way;
    ActiveSheet.Names.Add Name:="nums", RefersToR1C1:="=Hoja1!R3C1:R8C1"
    And this de abap code;
    CREATE OBJECT application 'Excel.Application'.
    CALL METHOD  OF application  'Workbooks' = workbooks.
    CALL METHOD  OF workbooks     'Add' = workbook.
    SET PROPERTY OF application 'Visible' = 0.
    GET PROPERTY OF application 'ACTIVESHEET' = worksheet.
    SET PROPERTY OF worksheet 'Name' = 'Unidades'.
    *....fill cells...
    *Option 1;
    CALL METHOD OF application 'ActiveWorkbook' = o_workbook.
    CALL METHOD OF o_workbook 'names' = o_names.
    *Option 2;
    *CALL METHOD OF application 'ActiveSheet' = worksheet.
    *CALL METHOD OF worksheet 'names' = o_names.
    CALL METHOD OF o_names 'Add'
        EXPORTING
          #1 = 'nums'
          #2 = 'Unidades!R3C1:R8C1'.
    The problem is to instantiate the object o_name.  after "CALL METHOD OF o_workbook 'names' = o_names" if in debbuging I do double-click on the variable, it is empty.
    any idea?
    Thanks in advance.

    I did it !!!
      CALL METHOD OF application 'ActiveSheet' = worksheet.
      CALL METHOD OF worksheet 'Cells' = o_cellstart
        EXPORTING
        #1 = 3
        #2 = 1.
      CALL METHOD OF worksheet 'Cells' = o_cellend
        EXPORTING
        #1 = 184
        #2 = 1.
      CALL METHOD OF worksheet 'range' = range
        EXPORTING
        #1 = o_cellstart
        #2 = o_cellend.
      CALL METHOD OF range 'select'.
    SET PROPERTY OF range 'Name' = 'nums'.

  • Creating an xml file from abap code

    Hello All,
    Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
    Thanks in advance,
    Paul.

    This has been discussed before
    XML files from ABAP programs

  • UNIX command in ABAP code

    Hi All,
    I need to use unix command (MOVE) in ABAP code for transfering a file from one directory to another directory.
    Can any one help with how to used unix commands in ABAP?
    Thanks in advance.
    Regards,
    Hemendra

    The recommended approach always used to be to use transaction SM69 to define a "soft" command name to the operating system command so that it could be configured to work across Windows, Unix etc.  For example:
    Command name       OS         Type             OS command                                 Parameters for operating system command 
    Z_FILE_MOVE        SunOS      Customer    mv                                                 ? ?   
    You can then call function module SXPG_COMMAND_EXECUTE (quite well documented) to actually perform the command passing in the appropriate number of parameters.
    Jonathan

  • Needs sample ABAP code for field routine

    Dear Expert,
    There is a field "Pay Scale Group" in my DSO which stores the data in the format
    AA1/B1/CCC2/DD2/EEE1, A1/BB2/CC2/DDD3/EE2 etc. These data has to be transferred to
    InfoCube where "pay Scale Group" in the InfoCube will store the data like EEE1,EE2 etc.
    I need to write a field routine on the transformation between DSO and Cube.
    Can any one please help me with the sample ABAP code for this scenario.
    Some more examples for better understanding of the requirement:-
    Data in DSO(Source)            Data in Cube(Target)
    ===================            ===================
    AA1/B1/CCC2/DD2/EEE1            EEE1
    AAA1/BB2/CC1/DDD3/EE2           EE2
    A2/BBB2/CC2/DDD3/EEE5           EEE5
    AA2/BB1/C1/DDD3/EE3             EE3
    A3/B1/CC2/DDD1/EE4              EE4
    Many thanks in advance.
    Regards,
    Prakash
    Please do not dump your code requirements in SDN
    Edited by: Pravender on May 18, 2011 11:37 AM

    Hi,
    You can use the following code :
    Suppose the technical name of the field coming from DSO is ZPAY_SGRP.
    And also for example let me take one record, that is ZPAY_SGRP = AA1/B1/CCC2/DD2/EEE1 .
    My assumption is that there will always be 4 '/'.
    In the field routine write the below code
    data: V1(5) type c,
              V2(5) type c,
             V3(5) type c,
              V4(5) type c,
             V5(5) type c.
    data : VAR1 TYPE /BIC/OIZPAY_SGRP.
    split VAR 1  at '/' into V1 V2 V3 V4 V5.
    result = V5.
    V5 will be having the characters after the last '/' .That is V5 = EEE1.
    Hope the above reply was helpful.
    Kind Regards,
    Ashutosh Singh
    Edited by: Ashutosh Singh on May 17, 2011 3:53 PM
    Edited by: Ashutosh Singh on May 17, 2011 4:17 PM

  • 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.

  • ABAP code for BI 7.0 transformations start routine

    Hi all,
    I am trying to update data from DSO1 (Source1: transaction data) to Infocube(TARGET)
    In the transformations Start routine, I have to read DSO2(Source2: Master data) for some fields.
    DSO1 has CUSTOMER as part of key
    DSO2 has CUSTOMER (key) and other fields....FIELD1, FILED2, FIELD3
    Infocube to be updated with FIELDS1,2 & 3 WHILE READING DSO2.
    WHERE DSO1 CUSTOMER matches with DSO2 CUSTOMER.
    Also, data NOT TO BE UPLOADED into Infocube if FIELD1 in DSO2= NULL
    Please give me the abap code for the above logic.
    Appreciate any help in this regard.
    Thanks.

    This is a doc from this site:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6090a621-c170-2910-c1ab-d9203321ee19
    Ravi Thothadri

  • ABAP code needed to convert from 0calmonth2 & 0calyear to 0calmonth

    Hi SAP GURUS,
    Can anybody give me the ABAP code to convert from 0calmonth2 and 0calyear to 0calmonth.and please suggest me whether i have to write start routine or end routine in transformations.
    Thanks ALL.

    hi,
    in the transformation map 0calmonth2 and 0calyear to the 0calmonth field, and from drop down choose routine.
    there will be an area where it will be mentioned write your piece of code below this line.
    paste the below code:
    Concatenate source_fields-0calmonth2 source_fields-0calyear into result.
    also delete the line result = .
    save the routine and execute the package.
    regards,
    Arvind.

  • Update Routine - ABAP code

    Hi,
    I am trying to write an update routine to calculate and populate fields in my ODS infoprovider.
    one of the key figure field in my update rules is 'No. of Days'. Based on the 'No. of Days' range, I want to send a key figure(Infoobject:Due amount) value to another infoobject(Bucket1, Bucket2, Bucket3 ect.)in my ODS infoprovider. For example, let's say,
    IF NO. OF DAYS = >0 AND <=30
       THEN TAKE THE DUE AMOUNT PUT IN BUCKET1
    ENDIF.
    ELSE IF
       NO. OF DAYS = >31 AND <=60
       THEN TAKE THE DUE AMOUNT PUT IN BUCKET2
    ENDIF.
    ELSE IF
       NO. OF DAYS = >61 AND <=90
       THEN TAKE THE DUE AMOUNT PUT IN BUCKET3
    ENDIF.
    I think, I know the data flow logic but I don't know how to code in ABAP language. If someone can give me some psuedo like ABAP code, I would appreciate your help with points.

    Hi Roa,
    I would do this in the start routine of the update rule.
    Here is a sample on how do this. You could use a case statement for this code also.
    Loop at Data_Packet.
    IF NO. OF DAYS = >0 AND <=30
    Data_Packet-BUCKET1 = DUE AMOUNT
    ELSEIF
    NO. OF DAYS = >31 AND <=60
    Data_Packet-BUCKET2 = DUE AMOUNT
    ENDIF.
    ELSEIF
    NO. OF DAYS = >61 AND <=90
    Data_Packet-BUCKET3 = DUE AMOUNT
    ENDIF.
    modify data_packet.
    endlloop.
    Cheers! Bill

Maybe you are looking for

  • Songs I purchased show up in my list of downloaded and in my music library, but then when iclick on them, it says cannot locate. Hope someone can help

    My computer is authorized, songs show up as purchase but they cannot be located, i checked the actual itunes folder and the entire album folder is in there but its empty! the songs still show up in my iphone. i transfered purchases. I have no idea wh

  • Logging option in materialized view

    Hi all, Anyone know about the meaning of "Logging option"(LOGGING, NOLOGGING) in Materialized view of node Snapshot in Oracle enterprise manager(Warehouse -->Summary management -->Materialized view(snapshot)) Pls explain me. Thank you Mcka

  • Report doesn't show some parts in some computers

    Hello I am currently stumped as to why one of the oracle reports that were made wont display properly on some selected computers. The system is installed in a dedicated server and the user's computers also have installed oracle's on them, no db. Perh

  • Teststand OI

    Hello, I've built a VI which captures events from a third-party software. When one of these event fire I have a case structure which needs to run a specific TestStand sequence with several input parameters and to receive the output message from this

  • How to manage image without save it on db

    dear all, my goal is don't store image into db but only save the path that ponit to them in a db tupla. Is this achievable? Thanks in advance kind regards carmelo Pace