BAPI Web Service

Hi,
I need to create a web dynpro component that will use a SAP provided webservice (e.g. BAPI_PERSDATA_GETDETAILEDLIST) and display the results.
Now the access to the webservice WSDL provided by the R/3 server requires authentication. So when I tried to create a Model using the Web Service WSDL it fails as there is no option to provide the usr/pwd.
e.g. the WSDL on my server is located at http://<server>:8000/sap/bc/soap/wsdl11?services=BAPI_PERSDATA_GETDETAILEDLIST&sap-client=500
This is the wsdl that I specified in the create Model in NWDS. It does not work....Is there some setup of the usr/pwd in NWDS that I need to do for this....
Please help!!
Regards,
-Navin

Hi Navin,
is the webservice indivisually working fine? if it works fine then u can use the WSDL link directly in webdypro model.
Regards
srikanth

Similar Messages

  • Problem while testing a BAPI Web Service

    i face this problem in web service bapi when i am carrying out the test... so can anyone help me???
    HTTP/1.1 500 Internal Server Error
    Set-Cookie: <value is hidden>
    content-type: text/xml; charset=utf-8
    content-length: 803
    sap-srt_id: 20080610/144609/v1.00_final_6.40/DD36B8E7DE44B5F19BA900145E6770F3
    server: SAP Web Application Server (1.0;700)
    <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Body><soap-env:Fault><faultcode>soap-env:Client</faultcode><faultstring xml:lang="en">Deserialisation failed</faultstring><detail><n0:SimpleTransformationFault xmlns:n0="http://www.sap.com/transformation-templates"><MainName>/1BCDWB/WSS0080610064309718000</MainName><ProgName>/1BCDWB/WSS0080610064309718000</ProgName><Line>128 </Line><Valid>X</Valid><ReferenceFault><DescriptionText>Error accessing the ref. node 'EMPLOYEENUMBER'</DescriptionText><RefName>EMPLOYEENUMBER</RefName></ReferenceFault><Caller><Class>CL_SRG_RFC_PROXY_CONTEXT</Class><Method>IF_SXML_PART~DECODE</Method><Positions>1 </Positions></Caller></n0:SimpleTransformationFault></detail></soap-env:Fault></soap-env:Body></soap-env:Envelope>

    There is SAP Note no. 830340 addressing this issue.
    https://websmp106.sap-ag.de/~form/handler?_APP=01100107900000000342&_EVENT=REDIR&_NNUM=830340&_NLANG=E
    Pl try to apply that SupportPack and let us know the results after that.
    Also pl reward points as appropriate.

  • BAPI Web Service Context Mapping Problem

    Hello all,
                 I am developing a process consisting of an automated activity.
    This automated activity uses a logical destination for a web service call to an ECC BAPI.
    The BAPI name is 'BAPI_INQUIRY_CREATEFROMDATA2'
    Now the problem is the Output mapping in the automated activity which calls the web service for the above BAPI has the response name as 'BAPI_INQUIRY_CREATEFROMDATA2.Response'
    So when i try to map the nodes it gives me an error, 'Error at Line 2, Column 29, Found '.' after BAPI_INQUIRY_CREATEFROMDATA2'.
    Since there is no mapping i do not get the process working
    If i remove the '.' from the wsdl file source, mapping is done. But the backend service call gives an error.
    How can i solve this problem?
    Any inputs will be very helpful.

    Hello Martin,
                     thnks a ton for your replies.
    The '.' is a standard thing.
    Its the part of the WSDL file which is a standard WSDL file for a service offered for a standard SAP BAPI. So i haven't changed anything.
    Its what is standardly available. So i cant anything on that.
    And the response element is not below the bapi node.
    The name of the root node of the BAPI return context is
    "BAPI_INQUIRY_CREATEFROMDATA2.Response"
    This is what is causing the problem.
    Please note here that '.' is not responsible for any hierarchy. Its the name of one single root node element.

  • Accessing BAPI web services from CAF External Services

    We have wsdl files that corresponds to BAPI calls.  Using CAF, we want to create an external service using those wsdl files and then create an application service which will be in turn used by web dynpro for developing our composites. We did the following steps:
    1. Created a new  Composite Application Service project
    2. Then right click on the External Services, select import, choose Web service.
    3. Select 'Local File System or URL' option. Copy the URL from the wsdl file and pasted the URL in the 'Browse' text field and click Next. Got an error in loading the web service.
    4. Removed the Proxy Server settings in Developer Studio but in vain. Tried all possible combinations with the URL also (such as with and without the wsdl key at the end of the URL and using the 'UDDI or URL' option under the Proxy Definition of the External Services Import and also with the Window => Preferences => Proxy settings).
    5. Since the above options failed, copied the wsdl files to the local drive and then choose that WSDL from the file system. Able to import.
    6. Created the application service and provided the custom code for the request and response.
    7. Registered the external service in the CAF browser -> Administrative tools -> External Service Configuration
    8. Tested the service through the Developer Studio.
    The error I get is: ERROR: IOError while working with the message. Check the nested exception: Connect Refused: connect:
    Any idea on what needs to be done to resolve it?

    authentication is required at design time to read the wsdl from bapis. did you provide username and password when importing the web service.
    you can always add the username and password to the url to see if you can successfully get to the wsdl. Like that http://<webas_abap_servername>:<portnumber>/sap/bc/soap/wsdl11?services=BAPI_PO_CREATE&sap-client=<clientnumber>&sap-user=<username>&sap-password=<password>

  • Sample code to access BAPI Web services from JAVA required

    Hi All,
    I am a java developer. I am new to SAP. I just want to know how to use the web services from ABAP
    I got the WSDL, and able to convert the WSDL into java classes using java2wsdl command.
    Now i want to know how to use these classes, in my java class.  i want to know two things
    1) How to get authentication or session  or token to use the service
    2) How to consume BAPI services by using above session or token.
    Any help, really appreciated. Plz help me if any one knows.
    Thanks alot,
    Mohan

    Triplehhh wrote:
    Hi,
    I have a web application developed with java,jsp and javascript and server used is weblogic.
    Now this application is running fine on my PC. I assume from this that there is no client side Java. Is this right?
    So what steps are required so that I can access the application from other PCs also.If there is no client side Java then you have to do nothing other than make sure your PC can be reached from the other PCs. i.e. no firewalls blocking the access and routing available between the client PC and the server PC.
    I don't see what this has to do with JNLP. Am I missing something?

  • Servlet calling a BAPI Web Service...

    Hi everyone,
    I downloaded the wsdl file for the BAPI_USER_GETLIST.
    I created a Deployable Proxy that points to this wsdl file.
    I created a Web modul project with a servlet.
    I also created an Enterprise application project that contains my Web modul project.
    In the Web modul project, I created  a servlet :
    Here is the code of the servlet :
    <b>try {               
         InitialContext ic = new InitialContext();                    
         BAPI_USER_GETLISTService sampleWS = (BAPI_USER_GETLISTService)ic.lookup("java:comp/env/SampleWSProxy");
         BAPI_USER_GETLISTPortType vi = sampleWS.getLogicalPort();
         BAPI_USER_GETLIST importParams  = new BAPI_USER_GETLIST();
         ArrayList list = new ArrayList();
         BAPIUSNAME structure = new BAPIUSNAME();
         structure.setUSERNAME(new String());
         structure.setFIRSTNAME(new String());
         structure.setLASTNAME(new String());
         structure.setFULLNAME(new String());
         list.add(structure);
         BAPIUSNAME[] rows = new BAPIUSNAME[list.size()];
         list.toArray(rows);
         importParams.setUSERLIST(rows);
         importParams.setWITH_USERNAME("X");
         BAPI_USER_GETLISTResponse exportParams = null;
              BAPIUSNAME[] res = vi.BAPI_USER_GETLIST(rows,"");
              for(int i=0;i<res.length;i++)
                   response.getWriter().write(res<i>.getFIRSTNAME());
    } catch(Exception e)
              response.getWriter().write("ERROR!!!" + e.getMessage());
    </b>
    The exception is :
    <b>ERROR!!!Service call exception; nested exception is: com.sap.engine.services.webservices.jaxrpc.exceptions.InvalidResponseCodeException: Invalid Response Code: (401) Unauthorized.</b>
    Can someone help with this security problem ?
    Is the code OK except the security problem ?
    Thanks a lot.

    Hi David,
    Before calling a BAPI, we have to make a connection to
    R/3. Try following code...
    import com.sap.mw.jco.*;
    public class TutorialConnect1 extends Object {
       JCO.Client mConnection;
       public Connect1() {
         try {
           // Change the logon information to your own system/user
           mConnection =
              JCO.createClient("001", // SAP client
                "<userid>", // userid
                "****", // password
                null, // language
                "<hostname>", // application server host name
                "00"); // system number
           mConnection.connect();
           System.out.println(mConnection.getAttributes());
           mConnection.disconnect();
        catch (Exception ex) {
          ex.printStackTrace();
          System.exit(1);
      public static void main (String args[]) {
        Connect1 app = new Connect1();
    This code from sap help, for details visit this link..
    http://help.sap.com/saphelp_erp2004/helpdata/en/bc/42e13d82fcfb34e10000000a114084/frameset.htm
    Hope this helps.
    Regards,
    Narinder Hartala

  • BAPI Web Service problem...

    Hi everyone,
    I do not success executing a simple BAPI like BAPI_COMPANYCODE_GETLIST.
    In my Controller : I connect the controller to the model and "drag and drop" the Request_BAPI_COMPANYCODE_GETLISTPortType_BAPI_COMPANYCODE_GETLIST context.
    In the wdDoInit() method, I wrote :
        Request_BAPI_COMPANYCODE_GETLISTPortType_BAPI_COMPANYCODE_GETLIST req =
             new Request_BAPI_COMPANYCODE_GETLISTPortType_BAPI_COMPANYCODE_GETLIST();
         wdContext.nodeRequest_BAPI_COMPANYCODE_GETLISTPortType_BAPI_COMPANYCODE_GETLIST().bind(req);
    No need to initialize a parameter because the BAPI doesn't required.
    I created a method for the execution:
      public void executeWS( )
        //@@begin executeWS()
        try {
             wdContext.currentRequest_BAPI_COMPANYCODE_GETLISTPortType_BAPI_COMPANYCODE_GETLISTElement().modelObject().execute();
             wdContext.nodeResponse().invalidate();
        } catch(Exception e) {
        //@@end
    I the logical port located in the model, I did not change anything. But something is strange. The target address is, lets say, : http://<server>:<port>/sap/bc/soap/rfc.
    If I copy and past this URL to my internet browser, I get: "The page cannot be displayed".
    Can someone help me ?
    Thank you in advance.

    Hi David,
    As you said, when you are giving URL, got from logical port of the model, in browser. You get page can not be displayed, right?
    Means, there is problem in link to your WSDL file location.
    And for setting username and password, don following.
    before executing your model set your username and password.
    wdContext.currentRequest_BAPI_COMPANYCODE_GETLISTPortType_BAPI_COMPANYCODE_GETLISTElement()._setUsername("<user name>");
    wdContext.currentRequest_BAPI_COMPANYCODE_GETLISTPortType_BAPI_COMPANYCODE_GETLISTElement()._setPassword("<password>");
    if you want to check that url then type following:
    http://<server>:<port>/sap/bc/soap/rfc?wsdl
    Let me know the status,
    Regards,
    Bhavik
    wdco
    Message was edited by: Bhavik Devisha

  • Async Interface being called synchronously via Web service/SOAP

    Hi,
    I have an asynchronous interface to receive data into XI which is being sent to a file system, I can successfully use this interface to send data to XI using the file sender communication channel, and the monitoring shows the same as asynchronous.
    The problem is when i want to use the same setup to send data from a .Net client using SOAP/Web service. This time if I go to monitoring I get to see that the call is synchronous..????... which is quite baffeling...
    I am not calling the XI webservice in synchronous mode I am calling the BeginInvoke method thus making an async call.
    what is it that I have to do to get the interface to behave as async on being called from a webservice?
    Thanks
    Aniruddha

    Thanks guys. I do understand that this is a old post. However I cannot find the following information. I too have C# Web App call SAP PI BAPI web service getting [NullReferenceException: Object reference not set to an instance of an object.]
    Extract of WSDL: In the Request section: How do I initialize these fields:
    COMPTEGENERAL
                   ITEMS occurs 0 to unbounded.
                             NUMERO_OU_NO_DE_COMPTE String
                             COMPTE_GENERAL String
                             CENTRE_DE_COUTS String
                             MONTANT_DEVISE Decimal
    webservicename.COMPTEGENERAL[] = new Mywebservice.Request FromWS[0].ToString();// Does not Work.
       <xsd:element name="COMPTEGENERAL">
                <xsd:annotation>
                  <xsd:appinfo source="http://sap.com/xi/TextID">9ce79547e32411e2a321f4ce4610676a</xsd:appinfo>
                </xsd:annotation>
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="unbounded" name="ITEM">
                      <xsd:annotation>
                        <xsd:appinfo source="http://sap.com/xi/TextID">85ebea01eedf11e2bbe7f4ce4610676a</xsd:appinfo>
                      </xsd:annotation>
                      <xsd:complexType>
                        <xsd:sequence>
                          <xsd:element name="NUMERO_OU_NO_DE_COMPTE" type="xsd:string">
                            <xsd:annotation>
                              <xsd:appinfo source="http://sap.com/xi/TextID">85ebe9faeedf11e29c4bf4ce4610676a</xsd:appinfo>
                            </xsd:annotation>
                          </xsd:element>
                          <xsd:element name="COMPTE_GENERAL" type="xsd:string">
                            <xsd:annotation>
                              <xsd:appinfo source="http://sap.com/xi/TextID">85ebe9fceedf11e28cd7f4ce4610676a</xsd:appinfo>
                            </xsd:annotation>
                          </xsd:element>
                          <xsd:element minOccurs="0" name="CENTRE_DE_COUTS" type="xsd:string">
                            <xsd:annotation>
                              <xsd:appinfo source="http://sap.com/xi/TextID">85ebe9fdeedf11e2b57df4ce4610676a</xsd:appinfo>
                            </xsd:annotation>
                          </xsd:element>
                          <xsd:element name="MONTANT_DEVISE">
                            <xsd:annotation>
                              <xsd:appinfo source="http://sap.com/xi/TextID">85ebea00eedf11e2bdcbf4ce4610676a</xsd:appinfo>
                            </xsd:annotation>
                            <xsd:simpleType>
                              <xsd:restriction base="xsd:decimal">
                                <xsd:totalDigits value="18" />
                                <xsd:fractionDigits value="4" />
                              </xsd:restriction>
                            </xsd:simpleType>
                          </xsd:element>
                        </xsd:sequence>
                      </xsd:complexType>
                    </xsd:element>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:schema>
      </wsdl:types>

  • Problem while testing a BAPI Web Servicei face this problem in web service

    i face this problem in web service bapi when i am carrying out the submit test... so can anyone help me???
    HTTP/1.1 500 Internal Server Error
    Set-Cookie: <value is hidden>
    content-type: text/xml; charset=utf-8
    content-length: 803
    sap-srt_id: 20080610/144609/v1.00_final_6.40/DD36B8E7DE44B5F19BA900145E6770F3
    server: SAP Web Application Server (1.0;700)
    <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Body><soap-env:Fault><faultcode>soap-env:Client</faultcode><faultstring xml:lang="en">Deserialisation failed</faultstring><detail><n0:SimpleTransformationFault xmlns:n0="http://www.sap.com/transformation-templates"><MainName>/1BCDWB/WSS0080610064309718000</MainName><ProgName>/1BCDWB/WSS0080610064309718000</ProgName><Line>128 </Line><Valid>X</Valid><ReferenceFault><DescriptionText>Error accessing the ref. node 'EMPLOYEENUMBER'</DescriptionText><RefName>EMPLOYEENUMBER</RefName></ReferenceFault><Caller><Class>CL_SRG_RFC_PROXY_CONTEXT</Class><Method>IF_SXML_PART~DECODE</Method><Positions>1 </Positions></Caller></n0:SimpleTransformationFault></detail></soap-env:Fault></soap-env:Body></soap-env:Envelope>

    Hi,
    since I did not find that BAPI in my system: what is the exact name?
    Did you test the BAPI directly in ABAP, i.e. function builder SE37, successfully?
    Currently it looks to me as if you did not provide sufficient business data.
    Did you specify the employee number before executing the call?

  • Authentication while consuming a BAPI exposed as a web service

    Hi all,
          This is the scenario - I am consuming a web service in my web dynpro application. The web service is nothing but a BAPI which is exposed as WS.
    My query - how do I achieve authentication from the web dynpro application to the web service using SAP Logon ticket?
    In NWDS, after I import the Web service and create a WS model, there's a node called 'Logical Ports'. In that node, I've set the authentication type in the security tab as 'Use SAP Logon Ticket'. But that doesn't work.Is there any other configuration to be made?
    Also, immaterial of the type of authentication I specify(even if I specify 'no authentication'), only if I set the userid & password for accessing the backend in my code, does my application work!! Otherwise, it throws an authorization error!!
    I'm struck with this issue for quite sometime. Have gone through help.sap links and also SAP docs. Most of the docs deal with either security for an RFC model or for a Web service project(EJB). I am not able to find a solution for my case.
    Can somebody help me solve this?
    Points assured.
    Thanks & regards,
    M.Subathra

    Hi,
    Have a look at the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9bdcb279-0e01-0010-b5ac-ef7f99e44c68">following document</a> (or <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webservices/authentication%20of%20a%20ws%20client%20using%20a%20sap%20logon%20ticket.pdf">this one</a>).
    I hope it answers some of your questions.
    Kind regards, Jack

  • How to perform auth check on Web Service calling BAPI in R/3 via XI?

    Hi all,
    We are running Net weaver PI 7.0 SPS11 and 4.6C R/3 and working on proof-of-concept project using BAPIs exposed on XI as Web Services and called from external SOAP client (MS SharePoint). We got it working fine with HTTPS and SOAP protocol as Sender and RFC Adapter as Receiver to R/3.
    Now we want to add authentication and authorization to this scenario...authentication will probably be SSO and SSL/HTTPS, but we are wondering how to handle authorizations in R/3? RFC Adapter channel is configured with system user, so once BAPI is called this use runs transactions in R/3 and in R/3, where the authorization is checked, we have no visibility which user requested Web service…
    Is there any way we could extract user is from HTTP header and have it dynamically used in RFC Adapter channel config? Or maybe there is another way to handle this?
    Any insights how to resolve this issue will be greatly appreciated.
    Thanks
    Margaret

    We found solution, PP can be configured on XI to have user running transaction known on R/3 backend system, so authorizations can be invoked.

  • Any existing BAPI that can be wrapped and exposed as a web service ???

    Hi ,
    I am designing PI Collaboration Platform and that all about Monitoring across SAP ECC, SAP PI and Non-SAP applications.
    BUSINESS CASE: Some clients are  looking for a solution that allows there management some visibility into the end-to-end aspect of processes, we will limit our discussion to SAP ECC and PI.
    SOLUTION: BAM ultimately helps solve this problem at an enterprise level - however that is a heavy investment for most organizations - is there an alternative that we can provide ? Example a generic web service that can be invoked from a 3rd party tool to provide reports.
    We do have solution :
    We can configure Proxy adapter and can write Java web service to invoke a method to extract the data from ECC and one or more report generating methods based on the standard ( like PDF,EXCEL etc)
    but we are still looking  for an existing BAPI that can be wrapped and exposed as a web service ????
    Need solution for the above ?

    Hi Sanjay,
    Yes  BAM  has a bigger take, if you are looking for PI monitoring reports  then please have a look at the following blogs which might
    give you some insight.this basically deal with reading data from SXMB_MONI tables.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/909760cb-0ec8-2a10-4a96-ee8417acfbc9
    http://wiki.sdn.sap.com/wiki/display/Snippets/PIMonitoringFunctionality-FetchingDatafromSXMB_MONIStandardTables-PartI
    i dont think there is any BAPI as such atleast wrt to PI.
    Best Regards,
    Srinivas

  • Web Service for "Creating Sales Order" by using BAPI

    Hello All,
    I am trying to create a WS for "Creating Sales Order". The corresponding BAPI that I am using for this purpose is BAPI_SALESORDER_CREATEFROMDAT1. I am able to create the Web Service and run the WSDL on WS Navigator.
    But there is a problem whil executing the Web Service. In the interface of WS, we can only enter item level details of "Order Partner". So when I enter the details and click on Execute, it returns me an error message "Please enter Ship to Party and Sold to Party". I have already given these details.
    Does any one have any idea of what is going wrong?
    Regards,
    Abhishek

    As you suggested i have passed the suggested parameters in item level..But this time i was not ablet to create the SO also..earlier i am able to creat SO but not line item, But now ia m not able to creat salesdocuement also.
    Return talbe filled with belwo messages.
    S V4                   233 SALES_HEADER_IN has been processed successfully   
    E V1                   320 No item category available (Table T184 ZKB  TEXT )
    E V4                   248 Error in SALES_ITEM_IN 000000                     
    W V1                   555 The sales document is not yet complete: Edit data 
    E V4                   219 Sales document  was not changed

  • Have problem when generate Web Service from bapi function

    Dear all,
    Please kindly help me about generating Web Service from BAPI function, It does not success only this attached function.
    I have done so many function without any problems.
    I found 1 case that I use specific variable to be an import/ export then, it can't create as well.
    As for this one, I try so many changes but I can't success it as well.
    This is my function on R/3 4.6C, Dot net connector 2.0, Dot net Frame Work 1.1.
    FUNCTION Z_BAPI_ATTACHMENT_CREATE.
    ""Local interface: Type: Remote-enabled module
    *"  IMPORTING
    *"     VALUE(P_BOTYPE) LIKE  BORIDENT-OBJTYPE
    *"     VALUE(P_BO_ID) LIKE  BORIDENT-OBJKEY
    *"     VALUE(P_MSGTYP) LIKE  SOFM-DOCTP
    *"     VALUE(P_DOCTY) LIKE  BORIDENT-OBJTYPE
    *"     VALUE(P_RELTYP) LIKE  BRELTYP-RELTYPE
    *"     VALUE(P_FNAME) LIKE  RLGRAP-FILENAME
    *"     VALUE(P_OBJDES) TYPE  SO_OBJ_DES
    *"  EXPORTING
    *"     VALUE(RETURNMESSAGE) TYPE  CHAR50
    INCLUDE : <cntn01>.
    P_BOTYPE  TYPE  BORIDENT-OBJTYPE DEFAULT 'BUS2105'
    P_BO_ID   TYPE  BORIDENT-OBJKEY
    P_MSGTYPE TYPE  SOFM-DOCTP DEFAULT 'URL'
    P_DOCTY   TYPE  BORIDENT-OBJTYPE DEFAULT 'MESSAGE'
    P_RELTYP  TYPE  BRELTYP-RELTYPE DEFAULT 'ATTA'
    P_FNAME   TYPE  RLGRAP-FILENAME
    P_OBJDES  TYPE  SO_OBJ_DES
    TYPES: BEGIN OF ty_message_key,
    foltp TYPE so_fol_tp,
    folyr TYPE so_fol_yr,
    folno TYPE so_fol_no,
    doctp TYPE so_doc_tp,
    docyr TYPE so_doc_yr,
    docno TYPE so_doc_no,
    fortp TYPE so_for_tp,
    foryr TYPE so_for_yr,
    forno TYPE so_for_no,
    END OF ty_message_key.
    DATA : lv_message_key TYPE ty_message_key.
    DATA : lo_message TYPE swc_object.
    DATA : lt_doc_content TYPE STANDARD TABLE OF soli-line
    WITH HEADER LINE.
    First derive the Attachment's ( MESSAGE )document type.
    p_docty = 'MESSAGE'.
    CASE p_reltyp.
    In case of URls
      WHEN 'URL'.
        p_msgtyp = 'URL'.
    In case of Notes / Private Notes
      WHEN 'NOTE' OR 'PNOT'.
        p_msgtyp = 'RAW'.
      WHEN 'ATTA'.
    Take given parameter e.g. 'DOC', 'PDF' etc.
    P_MSGTYP = 'EXT'.
      WHEN OTHERS.
    ....exit
        EXIT.
    ENDCASE.
    Create an initial instance of BO 'MESSAGE' - to call the
    instance-independent method 'Create'.
    swc_create_object lo_message 'MESSAGE' lv_message_key.
    define container to pass the parameter values to the method call
    in next step.
    swc_container lt_message_container.
    Populate container with parameters for method
    swc_set_element lt_message_container 'DOCUMENTTITLE' p_objdes.
    swc_set_element lt_message_container 'DOCUMENTLANGU' 'E'.
    swc_set_element lt_message_container 'NO_DIALOG' 'X'.
    swc_set_element lt_message_container 'DOCUMENTNAME' p_docty.
    swc_set_element lt_message_container 'DOCUMENTTYPE' p_msgtyp.
    In case of URLs..it should be concatenated with &KEY& in the begining.
    CASE p_msgtyp.
      WHEN 'URL'.
      lt_doc_content = '&KEY&http://www.rmtiwari.com' .
        CONCATENATE '&KEY&' p_fname INTO lt_doc_content.
        APPEND lt_doc_content.
    In case of Notes or Private Notes, get the data from files on appl
    server or from wherever(? - remember background).
      WHEN 'RAW'.
        lt_doc_content = p_fname.
        APPEND lt_doc_content.
    In case of PC File attachments
      WHEN OTHERS.
        OPEN DATASET p_fname FOR INPUT IN BINARY MODE.
        IF sy-subrc EQ 0.
          DO.
            READ DATASET p_fname INTO lt_doc_content.           "2 of 27
            IF sy-subrc EQ 0.
              APPEND lt_doc_content.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
          CLOSE DATASET p_fname.
        ENDIF.
    ENDCASE.
    'DocumentContent' is a multi-line element ( itab ).
    swc_set_table lt_message_container 'DocumentContent' lt_doc_content.
    Size is required in case of File attachments
    DATA : lv_doc_size TYPE i.
    DATA : l_file_lines TYPE i.
    DESCRIBE TABLE lt_doc_content LINES l_file_lines.
    READ TABLE lt_doc_content INDEX l_file_lines.
    lv_doc_size = ( 255 * ( l_file_lines - 1 ) ) +
    STRLEN( lt_doc_content ).
    swc_set_element lt_message_container 'DOCUMENTSIZE' lv_doc_size .
    Refresh to get the reference of create 'MESSAGE' object for attachment
    swc_refresh_object lo_message.
    swc_call_method lo_message 'CREATE' lt_message_container.
    Get Key of new object
    swc_get_object_key lo_message lv_message_key.
    Now we have attachment as a business object instance. We can now
    attach it to our main business object instance.
    Create main BO object_a
    data: LO_IS_OBJECT_A type SIBFLPORB. "type SIBFLPORB is unknown, so I
    DATA: lo_is_object_a TYPE borident.
    lo_is_object_a-objkey = p_bo_id.
    lo_is_object_a-objtype = p_botype.
    LO_IS_OBJECT_A-CATID = 'BO'.
    Create attachment BO object_b
    data: LO_IS_OBJECT_B type SIBFLPORB. "type SIBFLPORB is unknown
    DATA: lo_is_object_b TYPE borident.
    lo_is_object_b-objkey = lv_message_key.
    lo_is_object_b-objtype = p_docty.
    LO_IS_OBJECT_B-CATID = 'BO'.
    *TRY.
    *CALL METHOD CL_BINARY_RELATION=&gtCREATE_LINK
    EXPORTING
    IS_OBJECT_A = LO_IS_OBJECT_A
    IS_OBJECT_B = LO_IS_OBJECT_B
    IP_RELTYPE = P_RELTYP.
    CALL FUNCTION 'BINARY_RELATION_CREATE'
      EXPORTING
        obj_rolea    = lo_is_object_a
        obj_roleb    = lo_is_object_b
        relationtype = p_reltyp
      EXCEPTIONS
        OTHERS       = 1.
    Check if everything OK...who cares!!
    COMMIT WORK.
    if sy-subrc = 0.
      RETURNMESSAGE = 'S-Success'.
    else.
      RETURNMESSAGE = 'E-Error'.
    endif.
    ENDFUNCTION.
    Thanks in advance,
    Benjawan
    Edited by: Nitipat Chadchavalpanichaya on Oct 20, 2008 9:02 AM

    There is no any error message show up. It just the class
    Z_BAPI_ATTACHMENT_CREATE  doesn't create autometically as normal. I showed you as below.
    That means I can't call class z_bapi_attachment_create.
    ' <autogenerated>
    '     This code was generated by a SAP. NET Connector Proxy Generator Version 2.0
    '     Created at 21/10/2551
    '     Created from Windows
    '     Changes to this file may cause incorrect behavior and will be lost if
    '     the code is regenerated.
    ' </autogenerated>
    Imports System
    Imports System.Text
    Imports System.Collections
    Imports System.ComponentModel
    Imports System.Runtime.InteropServices
    Imports System.Xml.Serialization
    Imports System.Web.Services
    Imports System.Web.Services.Description
    Imports System.Web.Services.Protocols
    Imports SAP.Connector
      '@ <summary>
      '@ Client SAP proxy class
      '@ </summary>
      <WebServiceBinding(Name:="dummy.Binding", Namespace:="urn:sap-com:document:sap:rfc:functions")> _
      Public Class PRAttachment
        Inherits SAPClient
        '@ <summary>
        '@ Initializes a new PRAttachment.
        '@ </summary>
        Public Sub New()
        End Sub
        '@ <summary>
        '@ Initializes a new PRAttachment with a new connection based on the specified connection string.
        '@ </summary>
        '@ <param name="connectionString">A connection string (e.g. RFC or URL) specifying the system where the proxy should connect to.</param>
        Public Sub New(ByVal ConnectionString As String)
          MyBase.New(ConnectionString)
        End Sub
        '@ <summary>
        '@ Initializes a new PRAttachment and adds it to the given container.
        '@ This allows automated connection mananged by VS component designer:
        '@ If container is disposed, it will also dispose this SAPClient instance,
        '@ which will dispose a contained connection if needed.
        '@ </summary>
        '@ <param name="Cont">The container where the new SAPClient instance is to be added.</param>
        Public Sub New(ByVal Cont As Container)
          MyBase.New(Cont)
        End Sub
      End Class

  • Bapi as web service - required by schema description

    Hello,
    I exposed a BAPI as a web service. Lets take for example the bapi to update / change a business partner. When trying to update for example the first name I have to create a complex type: centralPersonData and I have to create ALL simple types that are subtypes of centralPersonData even when I only want to change one of this attributes otherwise I will get a:
    com.sap.engine.services.webservices.jaxrpc.exceptions.XmlMarshalException: XML Serialization Error. Property [...] of class [...] must exist and can not be null. This is required by schema description.
    I know that I get this error because the XML element tags are not created when I do not initialize the values. In the moment I initialize all values "by hand" and have to write sometimes about 50 lines of code only to update one value. Is there a better way to solve this?
    Thanks for your answers!
    Felix

    Hi
    Check This URL and you will get some Solutions to your problem
    http://help.sap.com/saphelp_nw04/helpdata/en/e9/ae1b9a5d2cef4ea4b579f19d902871/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/7c/a4f1b3c59aef4f8ea3c32cda0c0486/frameset.htm
    Regards
    Chandran

Maybe you are looking for

  • BUG: File History fails with no warning- Event ID 201

    I apologize for the long post but I want to summarize everything I've learned about this so far, as it looks like a critical bug. I am unable to get File History to backup my files with Windows 8.1.  I set up a 1 TB USB HDD as the target drive and it

  • I am unable to upload raw files from my Canon 7d ii, even after updating elements 12

    unable to up load raw files from Canon 7dii

  • Webcams for Toshiba TV's

    What web cam (Toshiba preferably) is compatible with Toshiba TV 50L7300U - thanks?

  • Ipad not chargind and not turning on

    Hello everyone. I tried to charge my battery yesterday with my 10W USB Power Adapter, but it seems that iPad isn't recognizing it as a power adatper, the same happens with a USB. When I press the on/off button, I see the following screen: http://supp

  • Document management doubt

    Hi, all 1.I have created a document by using  transaction CV01N as document:99 document type:WRP document part:000 document version :00 in this above document wrote as text to 1.accuracy 2.quality 3.delivery 2  Transaction code CT04 : created charact