How to execute a BADI in BAPI_ACC_DOCUMENT_POST from C#? - sap

I have to pass data to BAdI acc_document in parameter extension1 of BAPI bapi_acc_document_post, but i don't know how to do that using SAP .Net connector.
Any suggestions?
Regards, Devinder

BAPI extension parameters are pretty much free-form - as you can see, for BAPI_ACC_DOCUMENT_POST parameters EXTENSION1 and EXTENSION2 are defined as tables with character fields.
You can store whatever data you want to into them and use them as you do any other BAPI parameters, the key is that you need to interpret the values in your enhancement. For example, if the caller stores an external document number into a row of EXTENSION1, just interpret it as a document number when you use it in your BADI. If you're passing a structure in the extension parameter it can be a little trickier (as you have multiple fields to deal with), but the same principle applies.

Related

Do I need to convert a value?

While I was selecting a unit from a database table I noticed, via transaction SE16N, that there are two different values for the same field. An unconverted and a converted value. With my SELECT statement, I receive the unconverted one. Do I need to convert this value in order to continue working with it?
First of all, it's probably worth explaining what is the concept of "converted value" and "unconverted value" (what is better known as "external value" and "internal value").
Internal values are the actual values used by the programs and stored in the database, and the external values are only calculated at the time of the display, on screen, printout, and so on.
It's very practical to see a meaningful code, as Legxis explained, for the internal value of the unit of measure "ST" (a unit of measure which indicates that the number is a number of pieces, an English user would prefer to see PCS (English word "pieces"), while a German user would prefer to see ST (German word "Stücks").
The conversion algorithm is defined at the DDIC domain level (transaction code SE11) via the "conversion routine" field, a 5-character code which defines the conversion function modules which are called automatically at display time. For instance, the Unit of measure is related to the domain MEINS, which has the routine CUNIT which corresponds to the function modules CONVERSION_EXIT_CUNIT_INPUT and CONVERSION_EXIT_CUNIT_OUTPUT.
CONVERSION_EXIT_CUNIT_INPUT does the conversion from the external value (displayed) to the internal value (program and database)
CONVERSION_EXIT_CUNIT_OUTPUT does the conversion from the internal value (program and database) to the external value (displayed)
These function modules are automatically called in SAP rendering technologies like SAP GUI, SAPscript, Smart Form, SAP Adobe form, BSP, Web Dynpro, etc. The "OUTPUT" function module is also called if you call the ABAP statement WRITE.
Note that the "output length" defined for a DDIC domain may be of some importance, because one may define an output length (displayed) larger than the internal length. For instance, the language code is stored internally on one character but displayed on two characters. For instance, in English, the language code "V" (Sweden) is displayed "SW" (Sweden), and the language code "S" (Spain) is displayed "SP" (Spain).
Finally, if you understand well the concept, you should conclude that you usually don't need to convert anything yourself. It can be useful only if you want to define an interface which is not one of the SAP supported technologies mentioned above.
The table rows you SELECT in ABAP do only contain the unconverted values. Use these to e.g. JOIN with other tables or call methods/function modules. Conversion is only relevant when displaying the data.
By the way: Nonetheless these conversions with "good intentions" can cause problems. Values with type NUMC (numeric characters) for example are often trimmed/stripped during conversion when they have leading zeros. But some function modules do not work when these leading zeros are missing.

Regular expression search of Oracle BLOB field

I have a table with a BLOB field containing SOAP-serialised .NET objects (XML).
I want to search for records representing objects with specific values against known properties. I have a working .NET client that pulls back the objects and deserialises them one at a time to check the properties; this is user-friendly but creates a huge amount of network traffic and is very slow.
Now I would like to implement a server-side search by sending a regular expression to a stored procedure that will search the text inside the BLOB. Is this possible?
I have tried casting the column to varchar2 using utl_raw.cast_to_varchar2, but the length of the text is too long (in some cases 100KB).
dbms_lob.inst allows me to search the text field for a substring, but with such a complex XML structure I would like the additional flexibility offered by regular expressions.

Is There any way to check data for its Data type in VBA

I want to check Data in all excel sheet column to ensure that data is as per its specified data type.
Like in a numeric column there should not be char value.
Thanks in Advance.
Yes, use the same functions as you would in Visual Basic. isdate, isnumeric, etc. Make sure you test your data some. Some of the data type checker functions are not fool-proof, especially isnumeric. Here is one related thread to that Wrong result from IsNumeric() in VB.NET
There are many more out there if you search.
As mentioned in the other post, Excel has some built in functions which allow you to test data in a field. This works great for the front end. It should also be noted that the datatypes available in the front end Excel are not the same datatypes available in the backend VBA (they are similar but different).
Datatypes in VBA in the backend can be trickier than other languages for two reasons: 1) The Variant datatype (which is a nondescript datatype) and 2) VBA doesn't by default require you to specify the datatype of a variable (it will try and guess what you meant unless you use the Option Explicit command).
Check out the following articles on available VBA datatypes and converting between them:
Data Type Summary
Type Conversions in VB
Variant Data Type

Stored Proc with multiple parameters

I need a SP which can take some 24 input parameters to insert a record into a table. One way of sending multiple parameters is by using XML datatype. Any other best practice for sending multiple input parameter in SQL SP?
Any advise is appreciated!
If you're inserting only a fixed number of records, than you can define 24 parameters in your SP. This way you can get some compile-time checking, also you can define not-null, null or a default value for each parameter for greater flexibility.
I woudn't use XML datatype unless I have variable number of arguments or I must simulate parameter arrays (like in insert multiple orderlines at the same time).
If you're using SQL Server 2008 or higher there is support for Table-Valued Parameters. You can check this link for using table-valued params with .NET SqlCient, too
Vasile Bujac's answer is excellent and I agree with everything. But it may be worth adding that Sommarskog, a luminary MVP, has some very good articles on mimicing an array in SQL Server that may be very applicable to your situation. You can find them here: http://www.sommarskog.se/arrays-in-sql.html

SSIS - How do I see/set the field types in a Recordset?

I'm looking at an inherited SSIS package, and a stored procedure is sending records to a recordset called USER:NEW_RECORDS. It's of type Object, and the value is System.Object. It is then used for inputting that data to a SQL table. We're getting an error, because it seems that the numeric results of the stored procedure are being put in a DT_WSTR field, and then failing when it is then put into a decimal field in the database.
Most of the records are working, but one, which happens to have a longer number of decimal digits, is failing.
I want to see exactly what my SSIS recordset field types are, and probably change them, so I can force the data to be truncated properly and copied. Or, perhaps, I'm not even looking at this correctly. The data is put into the recordset using a SQL Task that executes the stored procedure.
Edit: It appears that this particular recordset is used twice, and this is the second use of it. I'm thinking that perhaps it has the data types of the first use. But I can't put a Data Viewer on a SQL Task, can I?
I am having the same trouble, so I directed the flow behind the record set into a flat file.
I did make a new recordset to use, so that the other one was not used. And while I never did figure out how to see the data, I could change the data types of the types in the parameter mapping, which was apparently what was needed. I changed a type from NUMERIC to FLOAT, and it quit complaining about some of the data.
This question may be too specific to my own problem to be of use to others. I may delete it.