Giter Club home page Giter Club logo

Comments (7)

ThaDafinser avatar ThaDafinser commented on August 25, 2024 1

This is the returned valued from SAP (i guess). That was also the behaviour in the PHP5 extension.

If i'm not wrong, SAP always fill the fields with whitespaces to the defined length of the column.

from php7-sapnwrfc.

danutavadanei avatar danutavadanei commented on August 25, 2024

@ThaDafinser I also think you are right.

@studio2222 Think of the following scenario, you receive a GUID from SAP result that is always 16 bytes long. After applying a recursive trim over all the array (I always did this to remove unused spaces) sometimes the last character of a GUID is a space, end of line or carriage return (happens) and you mess up the data. I lost many hours trying to figure out where I was wrong and it was the trimming.

from php7-sapnwrfc.

studio2222 avatar studio2222 commented on August 25, 2024

Yeah these 90/10 scenarios are tough. Previously we were using the saprfc connector which auto trimmed, and we detected this difference when comparing old version new results. However since it seems that 90% of the time trimming the values is more helpful and harmful, would you be ok adding a configuration setting that would turn trimming on? Say as part of the call function method or as maybe a global setting you can turn on/off?

from php7-sapnwrfc.

ThaDafinser avatar ThaDafinser commented on August 25, 2024

👎 for a configuration - this could lead to accidental errors like told by @avadaneidanut

Better an extra function, which does this job

from php7-sapnwrfc.

gkralik avatar gkralik commented on August 25, 2024

I'll look into this after my holiday...

from php7-sapnwrfc.

gkralik avatar gkralik commented on August 25, 2024

Back from holiday...

Initially, I planned to provide an option to automatically trim returned values. But the more I think about it, the less I think this would be good or the right way.

The developer should know what kind of values/data types to expect to be returned from SAP and therefore should decide whether to trim or not on a per item base. Letting the extension do the trimming just hides the fact that SAP has different data types, padding, etc. - and in my experience, such magic causes bugs.

Also, I would not be sure where to add an option for auto-trimming:

  1. Setting a global option does not feel right, as it might not be obvious which setting is effective at the time of calling an RFC.
  2. Adding a parameter to invoke() might work, though.

Using 2) might work, up until the time where you have RFCs that return complex and/or nested structures/tables where you would want one member to be trimmed, but not the other. So you end up doing the trimming manually anyways.

Personally, I use trim() manually on every item that I want to be trimmed. That way, I make the decision an explicit one and I always know the data I am handling.

from php7-sapnwrfc.

studio2222 avatar studio2222 commented on August 25, 2024

Ok, agreed. Not the end of the world. I've added code to trim all values coming back.

from php7-sapnwrfc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.