Quantcast
Channel: SCN: Message List - SAP Gateway
Viewing all 6105 articles
Browse latest View live

Re: Batch service passing multiple values as filters


Re: How to use OData service from Development and Quality using single gateway server.

$
0
0

You can go to the transaction /IWBEP/REG_SERVICE and then you can maintain the service to whatever naming convention you wanna follow. I hope that will solve your problem. 

fetched x-csrf-token 403 Forbidden when POSTING c# .NET

$
0
0

I am writing an app in .NET c# to call netweaver gateway services. GETS work fine. I get 403 Forbidden when I try a PUT. I know this is due to an issue passing the x-csrf-token in the POST, but I am using "Fetch" to get the x-csrf-token and passing it on the POST, so I don't know why it is not working. I have seen other posts by people having the exact same issue, but I have tried everything suggested in the replies without avail. What am I doing wrong ?

I have tried using "Postman" to manually fetch an x-csrf-token and use it in a POST (again using Postman) and this DOES work.

I have noticed that when I run my code:

1. I get a different value for the x-csrf-token every time I do the GET. Using Postman the same x-csrf-token is returned each time (until it expires and a new one is returned).

2. If I copy the x-csrf-token I fetch in code and paste it into Postman as the x-csrf-token for a POST then Postman FAILS (CSRF token validation failed).

3. If I copy the x-csrf-token manually fetched using Postman and paste it into my code as the token, my code still fails. This is really odd as that token continues to work if I use is for another POST using Postman - so it IS a valid x-csrf-token.

When I run my code, the "response" I receive back is:

response

{StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:

{

  Set-Cookie: MYSAPSSO2=AjQxMDIBABgAUABTAE0ASQBUAEgAMQAxACAAIAAgACACAAYAMAAyADADABAARwBXAEQAIAAgACAAIAAgBAAYADIAMAAxADYAMAA5ADEANAAxADEAMgAwBQAEAAAACAYAAgBYCQACAEX%2fAVYwggFSBgkqhkiG9w0BBwKgggFDMIIBPwIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBHjCCARoCAQEwbzBkMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTETMBEGA1UECxMKU0FQIFdlYiBBUzEUMBIGA1UECxMLSTAwMjA3MDE4MTgxDDAKBgNVBAMTA0dXRAIHIBQEBxFQATAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTYwOTE0MTEyMDI2WjAjBgkqhkiG9w0BCQQxFgQUjI3ZxiqW%21Ybw8UpMVrWuoa2mk10wCQYHKoZIzjgEAwQvMC0CFQCK%2fLbCDEUFUfTSAV85%2fVEw3R1VPgIUXoZhxKEizU7t2tZY4rwAONMbdEw%3d; path=/; domain=.globalinfra.net

  Set-Cookie: SAP_SESSIONID_GWD_020=MlioquPL-X_FSfCO_0i6SzycPex6bRHmqhPFcO6bdOM%3d; path=/

  x-csrf-token: Required

  Content-Length: 28

  content-type: text/plain; charset=utf-8

}}

    Content: {System.Net.Http.StreamContent}

    Headers: {Set-Cookie: MYSAPSSO2=AjQxMDIBABgAUABTAE0ASQBUAEgAMQAxACAAIAAgACACAAYAMAAyADADABAARwBXAEQAIAAgACAAIAAgBAAYADIAMAAxADYAMAA5ADEANAAxADEAMgAwBQAEAAAACAYAAgBYCQACAEX%2fAVYwggFSBgkqhkiG9w0BBwKgggFDMIIBPwIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBHjCCARoCAQEwbzBkMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTETMBEGA1UECxMKU0FQIFdlYiBBUzEUMBIGA1UECxMLSTAwMjA3MDE4MTgxDDAKBgNVBAMTA0dXRAIHIBQEBxFQATAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTYwOTE0MTEyMDI2WjAjBgkqhkiG9w0BCQQxFgQUjI3ZxiqW%21Ybw8UpMVrWuoa2mk10wCQYHKoZIzjgEAwQvMC0CFQCK%2fLbCDEUFUfTSAV85%2fVEw3R1VPgIUXoZhxKEizU7t2tZY4rwAONMbdEw%3d; path=/; domain=.globalinfra.net, SAP_SESSIONID_GWD_020=MlioquPL-X_FSfCO_0i6SzycPex6bRHmqhPFcO6bdOM%3d; path=/

x-csrf-token: Required

}

    IsSuccessStatusCode: false

    ReasonPhrase: "Forbidden"

    RequestMessage: {Method: POST, RequestUri: 'http://myserver:8000/sap/opu/odata/sap/ZGW_MAM30_SET_OP_STATUS_ORDER_SRV/SetOPOrderStatusSet', Version: 1.1, Content: System.Net.Http.ObjectContent`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], Headers:

{

  Accept: application/json

  Authorization: Basic UFNNSVRIMTE6U3BhMW45OTk=

  x-csrf-token: 1qvOVO8-COZXOpdc_pGdUQ==

  Cookie: MYSAPSSO2=AjQxMDIBABgAUABTAE0ASQBUAEgAMQAxACAAIAAgACACAAYAMAAyADADABAARwBXAEQAIAAgACAAIAAgBAAYADIAMAAxADYAMAA5ADEANAAxADEAMgAwBQAEAAAACAYAAgBYCQACAEX%2fAVUwggFRBgkqhkiG9w0BBwKgggFCMIIBPgIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBHTCCARkCAQEwbzBkMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTETMBEGA1UECxMKU0FQIFdlYiBBUzEUMBIGA1UECxMLSTAwMjA3MDE4MTgxDDAKBgNVBAMTA0dXRAIHIBQEBxFQATAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTYwOTE0MTEyMDIxWjAjBgkqhkiG9w0BCQQxFgQUjI3ZxiqW%21Ybw8UpMVrWuoa2mk10wCQYHKoZIzjgEAwQuMCwCFGg4S9qyJQVcVltix4A0zD0nN%21HBAhQJrXx35j9ImdBozmlwnFQtrGgNSA%3d%3d; path=/; domain=.globalinfra.net;SAP_SESSIONID_GWD_020=b86Ptk7cIZwHAO3uG8RbOzlcbLB6bRHmqg3FcO6bdOM%3d; path=/

  Content-Type: application/json; charset=utf-8

  Content-Length: 182

}}

    StatusCode: Forbidden

    Version: {1.1}

 

My code is below:

public class ZGW_MAM30_SET_OP_STATUS_ORDERController : ApiController

    {

        string userName =System.Configuration.ConfigurationManager.AppSettings["NetweaverUsername"];

        string pwd = System.Configuration.ConfigurationManager.AppSettings["NetweaverPassword"];

        string token = "";

        string cookieString = "";

        IEnumerable<string> cookies = new List<string>();

        CookieContainer cookieJar = new CookieContainer();

 

 

        System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["NetweaverUsername"], System.Configuration.ConfigurationManager.AppSettings["NetweaverPassword"]);

 

 

        public async System.Threading.Tasks.Task<string> Get()

        {

            try

            {

                using (var handler = new HttpClientHandler() { CookieContainer = cookieJar })

                using (var clientGet = new HttpClient())

                {

                    clientGet.BaseAddress = new Uri("http://myserver:8000/sap/opu/odata/sap/ZGW_MAM_ASSET_REFDATA_SRV/ZSYS004Set?$format=json");

                    clientGet.DefaultRequestHeaders.Accept.Clear();

                    clientGet.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    clientGet.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(

             "Basic", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", userName, pwd))));

                    clientGet.DefaultRequestHeaders.Add("x-csrf-token", "Fetch");

 

 

                    HttpResponseMessage response = await clientGet.GetAsync(clientGet.BaseAddress).ConfigureAwait(continueOnCapturedContext: false);

 

 

                    if (response.IsSuccessStatusCode)

                    {

                        HttpResponseHeaders headers = response.Headers;

 

 

                        token = response.Headers.GetValues("x-csrf-token").First();

                        cookies = response.Headers.GetValues("Set-Cookie");

  //This all seems to work

                    }

                    else

                    {

                        LogEntry("Error: response =" + response.StatusCode);

                        return null;

                    }

                }

 

 

                using (var client = new HttpClient())

                {

                    client.BaseAddress = new Uri("http://myserver:8000/sap/opu/odata/sap/ZGW_MAM30_SET_OP_STATUS_ORDER_SRV/SetOPOrderStatusSet");

                    client.DefaultRequestHeaders.Accept.Clear();

                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(

             "Basic", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", userName, pwd))));

                    client.DefaultRequestHeaders.Add("x-csrf-token", token);

 

 

                    cookieString = "";

                    foreach (string cookie in cookies)

                    {

                        cookieString += ";" + cookie;

                    }

                    client.DefaultRequestHeaders.Add("Cookie", cookieString.Substring(1));

//I'm not certain that "myContent" is correct for my Post, but I'm not getting that far ?

 

 

                    string myContent = "{'Message':'','UserId': 'CLEMOS','ActTime': '11:01:00','ActDate': '14.08.2016','InactiveStat': 'ACPTSITEACPTSITE','OpNo': '0010','OrderNo': '30528007','Status': 'ACPT','Stsma': ''}";

 

 

                    HttpResponseMessage response = await client.PostAsJsonAsync(client.BaseAddress, myContent).ConfigureAwait(continueOnCapturedContext: false);

//we get a response status code of 403                   

    if (response.IsSuccessStatusCode)

                    {

                        var receivedData = await response.Content.ReadAsStringAsync();

                        return "done";

                    }

                    else

                    {

                        LogEntry("Error: response =" + response.StatusCode);

                        return null;

                    }

                }

            }

            catch (Exception ex)

            {

                LogEntry(userName + " " + pwd);

                LogEntry("Error: exception = " + ex.Message);

                LogEntry("Error: exception = " + ex.InnerException);

                return null;

            }

        }

    }

SAP Gateway or PO REST adapters for mobile application

$
0
0

Hello Gateway Pros,

 

We have a mobile application that field technicians logon to tablets and perform various transactions ( for eg  enter time, create/post  parts order ) .

 

Currently we have a setup (  Non SAP mobile platform UI  <=> non SAP middleware with DB  <=>  legacy application ERP  ) which we be rolling out SAP to replace Legacy ERP.   existing  Mobile platform and  non sap middleware are designed to work together  for eg to process order when tablet goes offline.

 

We have  SAP PO  with REST adapter and SAP Netweaver gateway  in landscape ,  now the questions is  deciding which one would best suit  the scenario.

 

I have read various blogs  on SCN which has given me a good idea about the PO capabilities vs  Netweaver  but  I have few more questions

 

1) Can SAP Netweaver  good tool to use if we have to communicate large set of data any limitations ?

for eg  if the mobile application requests for all Parts in inventory and there customer pricing

 

2) PO comes with great monitoring tools does SAP Netweaver   has those capabilities

 

3) can SAP Netweaver handle offline scenarios  any link that explains offline scenarios will be great help ?

 

4) what are  the advantages  or disadvantages of using  SAP Netweaver over SAP PO  ( specific to my scenario )

 

 

Thanks for your time.

Raj

Re: Backup existing service?

$
0
0

It  doesn't work. One of the SInk file has error.

Re: Dealing With Customer ZBAPI which has multiple Input and Output Table Parameters(RFC/BOR Usage)

$
0
0

Hi Lakshman,

 

It sounds to me if you do 4 entity sets, you don't need 4 different OData URL.  It seems you need to set associations between entities and maybe NavigationProperty for EntityType as well. Then by calling one URL you can get all results back.

 

This is an example for standard OData for SRM Shopping Cart:

http://:/sap/opu/odata/GBSRM/CARTAPPROVAL;v=2/WorkflowTaskCollection('000000342035')/SCAHeader

It gets WorkflowTask and SCAHeader associated with WorkflowTask.

Other thing you can use $expand which is like inner join for SELECT statement.

Take a look into these:

http://scn.sap.com/community/gateway/blog/2014/09/24/lets-code-associationnavigation-and-data-provider-expand-in-odata-service

https://scn.sap.com/thread/3390745

Re: Error using $Batch -

$
0
0

Hi,

 

One more question I try insert many records from one request like

 

Request A(key is generate when insert the items from bapi) : [ 0 : { more than 1 field }

                                                                                           1: { more than 1 field }
                                                                                          ]

 

Can you tell if you know how can I read twice times the same data from sapui5 and what I need to do in method create please ?

 

Sorry if my english is wrong

 

Best Regards
Thanks for your time

Re: CORS Issue While Consuming ODATA from Gateway Hub

$
0
0

Hi Aggarwal, have you been able to solve this issue?

We have a custom SAPUI5 application that runs on a standalone laptop that needs to download / get data from SAP. We are receiving the same SOP / CORS 401 error messages. I've tried to change the return header from SAP via the gateway service method /IWBEP/IF_MGW_CORE_SRV_RUNTIME~READ_ENTITYSET

but with no luck.

 

call method super->/iwbep/if_mgw_core_srv_runtime~read_entityset

    exporting
      iv_entity_name           = iv_entity_name
      iv_source_name           = iv_source_name
      is_paging                = is_paging
      it_order                 = it_order
      it_filter_select_options = it_filter_select_options
      is_request_details       = is_request_details
    changing
      ct_headers               = ct_headers
      cr_entityset             = cr_entityset
*     cr_deleted_entityset     = cr_deleted_entityset
      cs_response_context      = cs_response_context.
*    ct_inline_info           = ct_inline_info.



  data ls_header  type ihttpnvp.

  ls_header-name = 'Access-Control-Allow-Origin'.
  ls_header-value = '*'.
  append ls_header to ct_headers.

  clear ls_header.
  ls_header-name = 'Access-Control-Allow-Credentials' .
  ls_header-value = 'true' .
  append ls_header to ct_headers.

 

 

 

And also in method /iwbep/if_mgw_conv_srv_runtime~set_header.

 

 

data: ls type ihttpnvp.

  ls-name = 'Access-Control-Allow-Origin'.
  ls-value = '*'.

  call method super->/iwbep/if_mgw_conv_srv_runtime~set_header
    exporting
      is_header = ls.


  ls-name = 'Access-Control-Allow-Credentials' .
  ls-value = 'true' .

  call method super->/iwbep/if_mgw_conv_srv_runtime~set_header
    exporting
      is_header = ls.

 


Re: CORS Issue While Consuming ODATA from Gateway Hub

$
0
0

Hi Jesse,

 

No we have not. I have a SAP OSS ticket opened too and SAP told that current version of the Gateway does not support CORS. We changed our architecture not to hit the gateway service directly but go through PHP server.

 

But in our scenario we are trying to access ODATA from the Non SAP HTML 5 application. In your case it seems to be SAPUI5 application. With SAPUI5 application we didn't have any issues as it was running on the SAP Gateway server itself.

 

Are you running the SAPUI5 on the local ABAP server?

 

Thanks,

Rohit

Re: CORS Issue While Consuming ODATA from Gateway Hub

$
0
0

Actually, this app. is a standalone app. on a laptop so to have the ability to work in remote isolated locations offline but still to have the ability to occasionally connect online.

 

So all the SAPUI5 "resources" / libraries are on the laptop. We just need to connect to the backend to download certain master data and to upload data once back in the office.

Re: SAP Gateway for transactional interfaces?

$
0
0

Hi Atanu,

Thank you for the details provided.

Using draft approach , Fiori apps can achieve collaboration, locking and usability features.

For custom UI5 applications NOT using S/4 HANA:

Do we have create OData services consuming BOPF objects and inturn BOPF framework will handle the locking(draft approach) implicitly ? Please suggest if there are any example implementation in the existing SAP NW releases to understand the methodology.

 

Appreciate your help.

 

Regards

Santhosh Kumar

Re: CORS Issue While Consuming ODATA from Gateway Hub

$
0
0

Does the user connecting to the Company network using VPN during the time SAPUI5 app connects to the backend server. If yes then you should not be getting this issue. If no then you will depending on if your gateway server is accessible from outside company network or not.

Insert multiple records with batch - Gatewy Netweaver

$
0
0

Hi Experts,

 

I have done some posts for understood the functionality batch. But I can't understand how can I insert many records from sapui5 for sap gateway netweaver

 

I have the following scenario:

table request.PNG

 

The users create items and this items need to be sent for sap gateway netweaver to generate the request with an existent bapi.

 

My doubt is how can I send many records in same request and how can I read this inside sap gateway in method created ?  Can you please share a tutorial or explain me how can I do this ?

 

Thanks very much for your help.

Best Regards
Cristina Rodrigues

How to call a batch request for Read in UI5...

$
0
0

Hi,

 

 

Can I get an example as to how to call a batch request for POST in UI5 for the below:

 

 

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

Accept: application/xml

 

GET ztotal_EmpSet/?$filter=StartDate+eq+datetime'2016-08-24T00:00:00'+and+EndDate+eq+datetime'2016-08-28T23:00:00'+and+Unit+eq+'50006636'+and+DateField+eq+'BASIC'+and+Id+eq+'1'HTTP/1.1

 

 

--batch--

 

Any link would also be helpful.

 

Code:

 

 

var allfilters = [new sap.ui.model.Filter({
  path:'filter1',
  operator : sap.ui.model.FilterOperator.EQ,
  value1 : this.filter1value
  }),
  new sap.ui.model.Filter({
  path:'DateField',
  operator : sap.ui.model.FilterOperator.EQ,
  value1 : 'BASIC'
  }),
  new sap.ui.model.Filter({
  path:'StartDate',
  operator : sap.ui.model.FilterOperator.EQ,
  value1 : oDateFormat.format(this.startDate.toDate())
  }),
  new sap.ui.model.Filter({
  path:'EndDate',
  operator : sap.ui.model.FilterOperator.EQ,
  value1 : oDateFormat.format(this.endDate.toDate())
  })];

  var batchrequest = this.oModel.createBatchOperation('/ztotal_EmpSet','GET',{
  filters : allfilters
  });
  this.oModel.addBatchReadOperations([batchrequest]); 
  this.oModel.submitBatch(this._gotData.bind(this),function(err){
  console.log(err);
  });

 

I am not getting values in the it_filter_select_options in the backend while debugging.

 

Regards,

Gopa

Re: Insert multiple records with batch - Gatewy Netweaver

$
0
0

Hello Cristina,

 

What is the operation you are doing ? POST ?

 

Regards,

Ashwin


Re: Insert multiple records with batch - Gatewy Netweaver

$
0
0

Hi Cristina,

 

Please check below link, that may help you.

 

Gateway Batch Calls from SAPUI5

 

And, in gateway you will get records one by one, In case you need, set a breakpoint in back end for batch operations, just set a break point in method CHANGESET_BEGIN or CHANGESET_END.

 

 

Regards,

Akhilesh

Re: How to call a batch request for Read in UI5...

$
0
0

You need to create your batch payload as shown below.

 

Sample one ->

 

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

 

GET get_emp_dataSet?$filter=Userid+eq+'00001' HTTP/1.1

 

 

--batch

Content-Type: application/http

Content-Transfer-Encoding: binary

 

GET get_emp_dataSet?$filter=Userid+eq+'00002' HTTP/1.1

 

 

 

--batch--

Re: Insert multiple records with batch - Gatewy Netweaver

$
0
0

Hello Ashwin ,

 

Yes, I want to do the operation post.

 

Best Regards,

Cristina

Re: Insert multiple records with batch - Gatewy Netweaver

$
0
0

Hi Akhilesh,

 

 

 

I saw this tutorial but anyone explain what I need to in method created and if I need make any change in methods CHANGESET_BEGIN and CHANGESET_END.

My question is , what is necessary to do in methods created , CHANGESET_BEGIN and CHANGESET_END for put the items I need in a table , but read one by one from http request ? For me is a little confused.

 

 

 

Because from what I understand is that the gateway can read many records but I don't know if this records need to be separated.

 

Thanks very much

Best Regards,
Cristina Rodrigues

 

 

 

 






Re: Urgent. Alias of Odata services in PROD

$
0
0

Hi All,

I have a problem like ,I have 2 client in a same server,

like dev and test,In my dev I have configured the all and its working fine and the status also green,

when I am opening the same service in test system its showing in yellow status,

and I am seeing no  system alias has maintained to my service,

Could you please help me on this.

Viewing all 6105 articles
Browse latest View live