Calling BAPI and manipulating using macros

Hello Guys,
Calling BAPI from SAP and manipulating the same using some macros or similar kind of code in MS Excel.
Can u give one example to the above scenario with step by step procedure.
thanks.
Regards,
reddy.

Hello Guys,
Calling BAPI from SAP and manipulating the same using some macros or similar kind of code in MS Excel.
Can u give one example to the above scenario with step by step procedure.
thanks.
Regards,
reddy.

Similar Messages

  • What is the interaction between calling VIs and subVIs using VI Server?

    I'm studying for the CLAD and one of the lines in NI's preparation document here is this:
    What is the interaction between calling VIs and subVIs using VI Server?
    I know how to use the "Call By Reference" function to call a VI, but not necessarily a subVI. I thought a subVI is always loaded with the calling VI and has nothing to do with VI Server. What am I missing?
    Solved!
    Go to Solution.

    Hi Bmihura,
    I think this article will clear up how the VI Server works with subVIs called dynamically or statically.
    Calling a VI by Reference
    Best Regards,

  • Call BAPI directly or use bus object types

    Hi,
    A quick question.
    At a customer, I need to create a targetgroup in a CRM system from an ABAP program
    I found that there exists the standard business object type BUS1185, what in fact has several methods which call BAPI functions ( for example BAPI_TARGETGROUP_CREATE )
    My question is know what is the best way to create the targetgroup, call the BAPI directly or use the object type ( via include <CNTN01> and the macro's SWC...
    Thanks in advance for your advice
    Erwin

    the only reason for using the BO macro's in regular ABAP programming, is if you want to emulate workflow behaviour, or if extra logic of the business object is needed (for instance if you have to know the content of several (virtual) attributes)). In the last case you also have to instantiate the BO.
    Other than that, just use the BAPI.
    Kind regards, Rob dielemans

  • JCo Calling BAPI and generate htm and xml page in output

    Friends,
            I am developing an Application in Java using JCO. The requirement there is a list of BAPI's are available for the selection, once the user select the BAPI , it will dynamically generates the screen of input parameters and than result will be stored in .htm and .xml file. It works for many BAPI's, but for few of that it won't work. Will you help me out why its gng to create problem for other BAPI's.
    e.g.
    BAPI_SALESORDER_GETLIST
    BAPI_PO_GETITEMS
    BAPI_MATERIAL_GET_DETAIL and few more...
    It doesn't generate the proper output of these BAPI's.
    Thanks.
    HItesh Shah

    Tanveer,
    There are many files so i wont be able to put the codes but let me tell u how i m doing.
    1) Giving the options to user in which server they want to connect.
    2) After connection has been established there is a plain text file available which consists the list of BAPI's which will be displayed in the list box.
    3) After user select any BAPI and press a button named 'DETAILS' it will display the Import/Export/Tables list.
    4) After clicking on Next , i m generating a dynamic screen for input parameters.
    5)Here is this step also one problem is that i have to write all the zeros, can u tell me if i want to pad the zeroes automatically what i will do.Becz every time the input parameters of each BAPI would be different.
    6) After getting input parameters i will generate the .htm and .xml file using writeXML and writeHTML function.
    7) I want to show them generated xml and html file in iexplore using clicking button...Can u tell me how to achieve that.
    Here is the code through which my xml and htm file will be generated.
    import com.sap.mw.jco.*;
    import java.io.*;
    import java.util.*;
    import java.math.*;
    import java.util.Iterator;
    // Quick imports
    import com.jxml.quick.QDoc;
    import com.jxml.quick.Quick;
      class RFCG {
          static final String SID = "R3";
          String conDetails []=new String[6];
          String ErrorMsg;
          int i=0;
          String LogonDetail;
          int Rows;
          IRepository repository;
          String InputName[]=new String[200];
          String InputType[]=new String[200];
          String OutputName[]=new String[200];
          String OutputType[]=new String[200];
          String OutputINTTYPE[]=new String[200];
          String OutputField[]=new String[200];
          String TableName[]=new String[500];
          String TableType[]=new String[500];
          String TableINTTYPE[]=new String[500];
          String FIELDNAME[]=new String[500];
          //String FIELDNAME[]=new String[20];
          String FIELDINTTYPE[]=new String[500];
          String OutputFieldType[]=new String[200];
          String OutputFieldINTTYPE[]=new String[200];
          String InputParFieldName[][]=new String[200][200];
          String InputParFieldDatatype[]=new String[200];
          String InputParFieldIntType[]=new String[200];
          int l,j,k,m,n,o,t,q;
           /** public static void main(String [] args){
                  new RFCG("SAPR3.txt");
             public RFCG(String LogonDetail,String BAPI)
                      this.LogonDetail=LogonDetail;
                      cleanUp();
                      try {
                                 /* for xml */
                                 // Initialize Quick
                                  QDoc schema = PersonSchema.createSchema();
                              // Convert input XML to Java
                                  QDoc doc = Quick.parse(schema, "input.xml");
                             // Get the result
                                  Person person = (Person)Quick.getRoot(doc);
                               for (Iterator i = person.getClientList().iterator(); i.hasNext(); ) {
                                            Client number = (Client)i.next();
                                           // String type=number.getType();
                                            //System.out.println(type);
                                           // System.out.println(LogonDetail+"LOGO");
                                            if(LogonDetail.equals(number.getType())){
                                                   //conDetails[0]=number.getType();
                                                   conDetails[0]=number.getSapclient();
                                                   conDetails[1]=number.getUserid();
                                                   conDetails[2]=number.getPassword();
                                                   conDetails[3]=number.getLanguage();
                                                   conDetails[4]=number.getHostname();
                                                   conDetails[5]=number.getSystemnumber();
                                            //System.out.println("  Client Type(" + number.getType() + "):");
                                          //System.out.println("  Sapclient " + number.getSapclient());
                                          //System.out.println("  Userid  " + number.getUserid());
                                          //System.out.println("  Password " + number.getPassword());
                                          //System.out.println("  Language " + number.getLanguage());
                                          //System.out.println("  Hostname  " + number.getHostname());
                                          //System.out.println("  Systemnumber  " + number.getSystemnumber());
                                          //System.out.println("   \n  ");
                               } catch (Exception e) {
                                     e.printStackTrace();
                      Connect(LogonDetail);
                      zbapi(BAPI);
                      new BapiParameters1(InputName,InputType,OutputName,OutputType,TableName,TableType,BAPI,repository,OutputINTTYPE,FIELDNAME,FIELDINTTYPE,OutputField,OutputFieldType,OutputFieldINTTYPE,LogonDetail,InputParFieldName,InputParFieldDatatype,InputParFieldIntType);
                      for (int i = 0; i < 10; i++) {
                               //System.out.println("STRING***RFCG*******"InputName<i>'\t'+InputType<i>);
         public void Connect(String LogonDetail){
         //CustName=CustName;
      /** try{
           File myFile = new File(LogonDetail);
           FileReader fr= new FileReader(myFile);
           BufferedReader reader=new BufferedReader(fr);
           String line=null;
           while ((line=reader.readLine())!=null){
                     String[] result=line.split(":");
                     conDetails<i>=result[1];
                     System.out.println(conDetails<i>);
                     ++i;
                reader.close();
           }catch(Exception ex){
                ex.printStackTrace();
               try {
                 JCO.addClientPool( SID,           // Alias for this pool
                                    10,            // Max. number of connections
                                    conDetails[0], // SAP client
                                    conDetails[1], // userid
                                            conDetails[2], // password
                                    conDetails[3], // language
                                    conDetails[4], // host name
                                    conDetails[5] );
                 this.repository = JCO.createRepository("MYRepository", SID);
                 //System.out.println("Connected"+ repository);
               catch (JCO.Exception ex) {
                 //System.out.println("Caught an exception: \n" + ex);
                 ErrorMsg=ex.toString();
                 //new Error(ex);
                 if (ErrorMsg!=null){
                      new Error(ErrorMsg);
             protected void cleanUp() {
                           JCO.removeClientPool(SID);
    public void zbapi(String BAPI)
        JCO.Client client = null;
        JCO.Table codes = null;
        try {
          // Get a function template from the repository
          //FunctionTemplate ftemplate = repository.getFunctionTemplate(person.getRFCName());
             IFunctionTemplate ftemplate = repository.getFunctionTemplate("FUNCTION_GET");
          // if the function definition was found in backend system
          if(ftemplate != null) {
          // Create a function from the template
            JCO.Function function = ftemplate.getFunction();
            // Get a client from the pool
            client = JCO.getClient(SID);
            // Fill in input parameters
            JCO.ParameterList input = function.getImportParameterList();
            input.setValue(BAPI, "FUNCNAME");
            client.execute(function);
            // Print return message
            //JCO.Structure ret = function.getExportParameterList().getString("NAME1");
              codes = function.getTableParameterList().getTable("PRMTAB");
                 //System.out.println("ROWS:"+codes.getNumRows());
                 this.Rows=codes.getNumRows();
                 //System.out.println(this.Rows);
              //System.out.println("PTYPE" + '\t' + "PNAME" + '\t' + "FIELDNAME" + '\t' + "DATATYPE");
         for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {
                                  //System.out.println(codes.getString("PARAMTYPE")+ '\t' +
                                  //codes.getString("NAME") + '\t'codes.getString("FIELDNAME")
                                  //'t' +codes.getString("DATATYPE"));
                                  if (codes.getString("PARAMTYPE").equals("1")){
                                        InputName[j]=codes.getString("NAME");
                                        InputType[j]=codes.getString("INTTYPE");
                                        //InputINTTYPE[j]=codes.getString("INTTYPE");
                                        ++j;
                                  else if(codes.getString("PARAMTYPE").equals("2")){
                                             OutputName[k]=codes.getString("NAME");
                                             OutputType[k]=codes.getString("DATATYPE");
                                             OutputINTTYPE[k]=codes.getString("INTTYPE");
                                             ++k;
                                  else if(codes.getString("PARAMTYPE").equals("3")){
                                             TableName[l]=codes.getString("NAME");
                                             TableType[l]=codes.getString("DATATYPE");
                                             TableINTTYPE[l]=codes.getString("INTTYPE");
                                             ++l;
                                       /**else if(codes.getString("PARAMTYPE").equals("5")){
                                            //System.out.println("RFCGGGGG"+InputParFieldName[o]);
                                             InputParFieldName[q][o]=codes.getString("FIELDNAME");
                                             if(t==0){
                                                  t=1;
                                                  //System.out.println("RFCGGGGG"InputParFieldName[o]"           "+t);
                                                        InputParFieldDatatype[o]=codes.getString("NAME");
                                              else{
                                                   int w=o-1;
                                                   System.out.println("OoOoOooo"w"\t"+o);
                                                   if(InputParFieldDatatype[w].equals(InputParFieldDatatype[o])){
                                                  //System.out.println("RFCGGGGG"InputParFieldName[o]"           "+t);
                                                  System.out.println("yes");
                                                 else{
                                                   InputParFieldDatatype[o]=codes.getString("NAME");
                                                   ++q;
                                             InputParFieldIntType[o]=codes.getString("INTTYPE");
                                                                                ++o;
                                  else if(codes.getString("PARAMTYPE").equals("6")){
                                            if(!codes.getString("NAME").equals("RETURN")){
                                                  //if(codes.getString("NAME").equals(TableName[]))
                                                  OutputField[n]=codes.getString("FIELDNAME");
                                                  //OutputFieldType[n]=codes.getString("DATATYPE");
                                                  OutputFieldINTTYPE[n]=codes.getString("INTTYPE");
                                                  ++n;}
                                  else if(codes.getString("PARAMTYPE").equals("7")){
                                             FIELDNAME[m]=codes.getString("FIELDNAME");
                                             FIELDNAME[m]=codes.getString("DATATYPE");
                                             //System.out.println("TABLEFIELD"+FIELDNAME[m]);
                                             FIELDINTTYPE[m]=codes.getString("INTTYPE");
                                             ++m;
          else {
                //System.out.println("Function not found"  );
                   //new Error("Function not Found");
            //System.out.println("Function BAPI_SALESORDER_GETLIST not found in backend system.");
          }//if
        catch (Exception ex) {
         System.out.println("Caught an exception: \n" + ex);
         ErrorMsg=ex.toString();
              //System.out.println("2222Caught an exception: \n" + ErrorMsg);
                   if (ErrorMsg!=null)
                               new Error(ErrorMsg);
         //        new Error(ex);
        finally {
          // Release the client to the pool
                    //System.out.println("2222Caught an exception: \n" + ErrorMsg);
          JCO.releaseClient(client);
    /**protected void cleanUp() {
                  JCO.removeClientPool(SID);
    Thanks,
    Hitesh

  • Known And Previously Used Macro Won't Run

    macro wont run
    Applies To: Office |
    Office 2007 |
    Microsoft Office Word | Windows 7
    I use a macro for a particular mail-merge operation, and have used it quite successfully on many occasions in the past.
    I have tried to run it over the last few days, but I keep getting a message saying it cannot be loaded due to my macro security settings.
    My security settings are correctly set; I have ensured that the macro is the latest version, and I am told (via developer ribbon) that the macro is loaded.
    Can anyone make any suggestions that I might try please.
    Thank you,
    Ian

    I had the same problem Ian, I'm not a Microsoft engineer (just a user) and I am using Word 2013 so take my advice with a word of caution.
    I created a couple of simple macros to reduce the number of keystrokes needed to perform actions that were repeated frequently. They worked as intended from the visual basic environment. They didn't work when I added them to the quick access toolbar. 
    1. I tried saving my document as a .docm then closed and reopened it, no joy I messed around with the toolbar without any success.
    2. I read the advice from Peter.
    2. I played with the trust center and ended up with following selections:
    Enable all macros (not recommended; potentially dangerous code can run)
    Trust access to the VBA project object model
    Now they work. Good luck
    Jeff
    Jeff,
    You should not need Trust All Macros (despite the advice from Peter). You do need to trust access to the VBA project model.
    Just either use signed projects or place your macro-enabled templates (or, if needed, documents) in a Trusted Location. I seldom put macros in documents directly.
    Save any QAT modification in the same template that stores the macro rather than for all documents.
    Modifying the QAT and Ribbon in Microsoft Word
    Charles Kenyon Madison, WI

  • Calling rows and columns using a script

    I have a file as such
    1 2 PX
    0.446E+00 0.867E+00-0.123E+00-0.372E+00 0.285E+00-0.640E+00-0.163E+01-0.658E+00
    -0.173E+00-0.845E+00-0.446E+00-0.366E+00-0.194E+01-0.194E+01-0.214E-01-0.400E-01
    -0.151E+01-0.167E+01-0.173E+01-0.232E+01-0.173E+01-0.121E+01-0.234E+01-0.277E+01
    -0.126E+01 0.940E+00 0.404E+01 0.659E+01 0.513E+01 0.198E+01 0.237E+01 0.518E+01
    2 2 PX
    0.315E+00 0.909E+00 0.104E+00-0.475E+00 0.141E+00-0.449E+00-0.156E+01-0.751E+00
    0.553E-01-0.626E+00-0.640E+00-0.494E+00-0.189E+01-0.213E+01-0.125E+00 0.285E+00
    -0.132E+01-0.180E+01-0.172E+01-0.232E+01-0.187E+01-0.103E+01-0.193E+01-0.268E+01
    -0.130E+01 0.974E+00 0.370E+01 0.610E+01 0.516E+01 0.218E+01 0.232E+01 0.522E+01
    3 2 PX
    0.217E+00 0.116E+01 0.552E+00-0.490E+00-0.892E-01-0.303E+00-0.125E+01-0.512E+00
    0.315E+00-0.672E+00-0.104E+01-0.559E+00-0.162E+01-0.222E+01-0.476E+00 0.166E+00
    -0.131E+01-0.167E+01-0.142E+01-0.234E+01-0.225E+01-0.901E+00-0.123E+01-0.218E+01
    -0.107E+01 0.994E+00 0.320E+01 0.551E+01 0.516E+01 0.225E+01 0.193E+01 0.502E+01
    4 2 PX
    0.110E+01 0.169E+01 0.538E+00-0.103E+01-0.487E+00 0.154E+00 0.134E+00 0.176E+01
    0.325E+01 0.179E+01-0.308E+00-0.155E+01-0.361E+01-0.457E+01-0.233E+01-0.505E+00
    -0.111E+01-0.130E+01-0.128E+01-0.288E+01-0.374E+01-0.274E+01-0.232E+01-0.160E+01
    0.147E+01 0.459E+01 0.612E+01 0.683E+01 0.511E+01 0.116E+01 0.203E+00 0.348E+01
    Where each section (1,2,3,4...) represents a different spring element.  The data is the force in the spring at time t reading from left to right and then on to the next row (i.e.  row1 col1 is time t(1), row1 col2 is time t(2), etc going across)
    I would like to sum the forces in each spring at time t (ie call the force at time t(1) for all elements and add them together.  So that in the end I have the sum of the forces in all elements at each time t.  I would then like to find the time t with the greatest sum and return to a file the force at that time for each element.
    Any help would be appreciated:)

    And now let's see what every part does (before I forget) and you want this right?
    Command 1:
    's/.*\([0-9][0-9]*\).*[0-9][0-9]* PX.* <-- matches the PX lines. "....1-inf numbers (Remember)...1-inf numbers space PX ....."
    /\nSPRING: \1/' < change to SPRING: the number above and an extra newline to make paragraphs which is useful for awk below.
    's/\([^E:]\)\([ -]\)/ <-- match a space or minus and the character before it (see NB 4 above)
    \1\n\2/g' <-- and put a new line between them. This way all the numbers are on a separate line
    'BEGIN { RS="";FS="\n"} <-- RS="" will match paragraphs.
    {for (i=2; i<NF+1; i++) { record[(i-1)]=record[(i-1)]+$i}} <-- Field 1 is SPRING: 9, otherwise record everything by adding up. awk can handle scientific notation.
    There is a i-1 with record because time starts at 1 and i at 2. This could all make more sense without the spring line.
    END {for (times in record) {print record[times] "\tt=" times}}'  <-- print the totals and the time that belongs with it.
    Command 2:
    grep 999t= <-- the output of the spring data will be of the form -999 just because it will be at the bottom of sort -rn.
    $(sed -e 's/.*\([0-9][0-9]*\).*[0-9][0-9]* PX.*/\nSPRING: \1/' -e 's/\([^E:]\)\([ -]\)/\1\n\2/g' file | awk 'BEGIN { RS="";FS="\n"} {for (i=2; i<NF+1; i++) { record[(i-1)]=record[(i-1)]+$i}  <-- identical as above.
    for (i=2; i<NF+1; i++) {data[(i-1)]=data[(i-1)] $i}} <-- this will append the actual string data as opposed to adding it up and losing the original data.
    END {for (times in record) {print record[times] "\tt=" times} <-- identical
    for (times in data) {print "-999t=" times " " data[times]}}'  <-- -999t= prepended because see above
    | tee tempfile.txt  <-- tee copies the data because we will match the top total force with the data of the spring
    | sort -nr | head -n 1 | cut -d= -f2  <-- gives the single highest force
    ) tempfile.txt  <-- Command becomes: grep '999t=high_number' tempfile
    | sed 's/[^ ]* *//' <-- get rid of garbage at the start.

  • From JCO calling BAPI and want to get the list

    Friends,
            Using JCO i connected to SAP server and want the list of profitcenter and all creditors.
    For Creditors    : BAPI_CREDITOR_GETDETAIL
    For Profit center: BAPI_PROFITCENTER_GETLIST
    I am using both the bapi's but i am not getting the list of it. Basically this two bapi will return table so..will u pls. help me out to solve this problem.
    Thanks
    Hitz

    Hi,
    probably you work wiht wrong data (if is something wrong with connection to SAP, some exception will erased).
    First connect to SAP with SAP gui, go to transaction se37 and try run BAPI_CREDITOR_GETDETAIL. That is a test do you work wiht correct data (in BAPI_CREDITOR_GETDETAIL creditorid is mandatory).
    Other you can do is: get bapi's return table (also export table) and read message.

  • Wont Make calls/texts and cannot use internet

    The other day I was texting someone then suddenly there was an error sending message then ever since then I can't text anyone, make any calls or use the internet. I can receive texts and calls just not make them.
    My payment isn't due untill the 2nd, I have gone over my contract but I have enough money in my bank account to pay for this... :S So I don't know if this will affect it...
    I've tried restoring it to factory settings and resetting everything but that didn't help.

    Nah I haven't done that yet, was planning to do so today but wanted to see if I could get any online help before... Am just checking to see if there is an easy solution or anything..

  • Using the container format to call BAPIs

    I'm trying to call BAPIs with the SWO_CREATE and SWO_INVOKE RFC's, and having a difficult time getting the container marshalled correctly.  Can anyone supply or point me to information about marshaling arguments in the container?
    Thanks

    Hi Jhon,
    I have seen your question for the container format to call BAPI and could not find any replies or any kind of information regarding the container marshalling on the web. I am having a simillar problem when invoking the SWO_INVOKE, i am passing a container and it gives me a error saying "packed field with incorrect BCD format" and i am trying to find some kind of solution for this, if you  had a some kind of solution or guidance that would be great.
    Thanks,
    Praveen

  • Difference between bapi and function module

    Can you guys tell me what are the differences in calling bapis and function modules?
    I see we are calling both as the same way we call function modules. May be for bapis, we need to be careful in declaring and passing those exact structures. Can you please make it clear reg. the differences between them?
    I appreciate it.
    Thanks!

    HI,
    See these links on help.sap.com
    <b>For BAPI:</b>
    The data entered in the Internet is transferred to the R/3 System via BAPIs (Business Application Programming Interfaces).
    Data in the R/3 System is accessed via BAPIs as well.
    A Good Site for BAPI's
    http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html
    http://help.sap.com/saphelp_erp2005/helpdata/en/7c/3ce38765ba11d395fe00a0c94260a5/frameset.htm
    <b>For Function Module:</b>
    The important use of functional module is it is used by Enhancements.
    SAP Enhancements are used to expand the standard functionality within SAP.
    Enhancements use function modules and are called from the standard SAP code.
    http://help.sap.com/saphelp_erp2005/helpdata/en/41/7af4daa79e11d1950f0000e82de14a/frameset.htm
    List of functional modules ( Good Site)
    http://www.geocities.com/victorav15/sapr3/abapfun.html
    Hope it helps!!!!
    Thanks
    Sudheer

  • How to invoke Internet Explorer and Adobe using OLE2

    Hi all
    We have to call IE and adobe using OLE2.
    how to do that ?
    Is it like how we do for word or excel. We tried that way but not working.
    e.g:
    app := OLE2.CREATE_OBJ('IExplore.Application');
    please help us.
    Thnx and regards
    Sriram

    The commands you pass are specific to the OLE service, so its not really a Forms question but a question for the OLE provider.
    Having said that - the questions I would ask is what are you trying to do? If you want to launch IE and display a PDF document you can do that with web.show_document. OLE will only work on the server and so the clients would not see IE if you were using OLE.
    REgards
    Grant Ronald
    Oracle Product Management

  • Connect NDS to r3 for calling bapi

    Hi,
    How can I connect netweaver developer studio to r3 for calling bapi and rfc?
    Many thanks,
    I'm new, very new, in the portal development.

    HI,
    How can I connect netweaver developer studio to r3 for calling bapi and rfc?
    will you elaborate more about what you want.
    1. If you wan to connect to R3 to create an RFC model for web dynpro project then.
       After creating the project, when you say create an adaptive rfc model a wizard will open
    where you can insert the information about server, as load balancing or single server.
    2. there you need to give information about host name, instance no,client, username and password.
        after that it will show you all the bapis.
    But there is nothing like connecting R3 to NWDS and calling bapi and RFC. as it is a development studio, form where you can develope an application.
    after deploying your application on J2EE server(WAS as Java), it will call a BAPI or RFC.
    for that you need to create JCO connections between your WAS as JAVA and R3 server

  • Anytime call plan and hub phone?

    I have been a BT customer for almost a year now, and have upgraded to anytime call plan, and i use 2 hub phones.
    I use the hub phones just like landlines, i make and recieve calls all the time wether computer is on or not.
    I am just wondering now, will my anytime UK free call plan prices still count, or will i be charged the minute rate for using hub phones?
    Appreciate any info
    Solved!
    Go to Solution.

    Two possibilities to consider.
    Assuming she doesn't have one already, you could get your daughter a basic unlocked mobile phone for less than £20. Then you can get a SIM-only deal from a supermarket (think beef lasagne) for a tenner a month for 500 minutes of calls and 5000 texts. You'll probably need to stress that it's 500 mins and 5000 texts a month, not a day.
    You could spend a one-off £30 on the recently-reduced BT6500; looks like a bargain right now. If gentle persuasion doesn't work you could then block calls to mobiles.
    You can click the white star next to this message if you think it was helpful.

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

  • Reading XML file using BAPI and then uploading that xml file data into SAP

    I am getting a xml file from Java server. I need to take
    data from this file using BAPI and need to upload into SAP using SAP.
    Please tell me how to read XML files using BAPI's.

    <b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML
    <b>SDIXML_DOM_TO_XML</b>  Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
    <b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
    <b>SDIXML_DOM_TO_DATA</b>
    data: it_table like t001 occurs 0.
    data: l_dom      TYPE REF TO IF_IXML_ELEMENT,
          m_document TYPE REF TO IF_IXML_DOCUMENT,
          g_ixml     TYPE REF TO IF_IXML,
          w_string   TYPE XSTRING,
          w_size     TYPE I,
          w_result   TYPE I,
          w_line     TYPE STRING,
          it_xml     TYPE DCXMLLINES,
          s_xml      like line of it_xml,
          w_rc       like sy-subrc.
    start-of-selection.
      select * from t001 into table it_table.
    end-of-selection.
    initialize iXML-Framework          ****
      write: / 'initialiazing iXML:'.
      class cl_ixml definition load.
      g_ixml = cl_ixml=>create( ).
      check not g_ixml is initial.
      write: 'ok'.
    create DOM from SAP data           ****
      write: / 'creating iXML doc:'.
      m_document = g_ixml->create_document( ).
      check not m_document is initial.
      write: 'ok'.
      write: / 'converting DATA TO DOM 1:'.
      CALL FUNCTION 'SDIXML_DATA_TO_DOM'
        EXPORTING
          NAME               = 'IT_TABLE'
          DATAOBJECT         = it_table[]
        IMPORTING
          DATA_AS_DOM        = l_dom
        CHANGING
          DOCUMENT           = m_document
        EXCEPTIONS
          ILLEGAL_NAME       = 1
          OTHERS             = 2.
      if sy-subrc = 0.  write  'ok'.
      else.             write: 'Err =', sy-subrc.
      endif.
      check not l_dom is initial.
      write: / 'appending DOM to iXML doc:'.
      w_rc = m_document->append_child( new_child = l_dom ).
      if w_rc is initial.  write  'ok'.
      else.                write: 'Err =', w_rc.
      endif.
    visualize iXML (DOM)               ****
      write: / 'displaying DOM:'.
      CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
        EXPORTING
          DOCUMENT          = m_document
        EXCEPTIONS
          NO_DOCUMENT       = 1
          OTHERS            = 2.
      if sy-subrc = 0.  write  'ok'.
      else.             write: 'Err =', sy-subrc.
      endif.
    convert DOM to XML doc (table)     ****
      write: / 'converting DOM TO XML:'.
      CALL FUNCTION 'SDIXML_DOM_TO_XML'
        EXPORTING
          DOCUMENT            = m_document
        PRETTY_PRINT        = ' '
        IMPORTING
          XML_AS_STRING       = w_string
          SIZE                = w_size
        TABLES
          XML_AS_TABLE        = it_xml
        EXCEPTIONS
          NO_DOCUMENT         = 1
          OTHERS              = 2.
      if sy-subrc = 0.   write  'ok'.
      else.              write: 'Err =', sy-subrc.
      endif.
      write: / 'XML as string of size:', w_size, / w_string.
      describe table it_xml lines w_result.
      write: / 'XML as table of', w_result, 'lines:'..
      loop at it_xml into s_xml.
        write s_xml.
      endloop.
      write: / 'end of processing'.
    end of code
    Hope this will be useful.
    regards
    vinod

Maybe you are looking for