cancel
Showing results for 
Search instead for 
Did you mean: 

Per Line Error

Former Member
0 Kudos

Hi Experts,

How can I detect the error per line item in DI API. Can u provide me a sample code thanks

Regards,

Phoenix Langaman

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi Phoenix,

What kind of error are you hoping to see ?

If you are looking for Data Validation error it is not possible.

The validation is only triggered when the Add/Update/Cancel method is called.

The best way for this is only by exporting the document to xml and examine it.

Regards

Edy

Answers (3)

Answers (3)

Former Member
0 Kudos

And also, what are the qualification of per item to meet the error(s)?

Former Member
0 Kudos

Hi Sir,

I need to determine all the error per line item in order for me to easily correct it before posting. But the problem is that the error on SAP triggers when .Add method is called and the error return only 1 line item per call but in reality the error contains 3 line item so as of now the problem is that the you need to call add method 3x in order to correct all the error before posting..

Former Member
0 Kudos

Before you post, you just add a validation. You will have 2 loops. 1 loop for the validation and 1 loop for add the line.

In the first loop. Put some query base on your requirements. For example:

Dim oQry as String

For i as integer = 0 to rowcount - 1

     oQry = "SELECT ItemCode FROM OITM WHERE ItemCode = '"& yourItem &"' "

     oRec.DoQuery(oQry)

     If oRec.RecordCount = 0 Then

          'Return Error

     End If

Next

In this example, I want to validate if my item is existing in my OITM table.

Regards,

edy_simon
Active Contributor
0 Kudos

Hi Phoenix,

There is no way you can validate the whole lines at the point Add().

What you can do to achieve this is to validate your self all the lines like Bryan showed you.

But this will be very tedious job, since you need to validate a lot of things.

a few things :

1. Item Code exists?, is it active?

2. WhsCode exists? Is the item maintained in this WhsCode? WhsCode Active ?

3. AccountCode bound to this item Active ?

4. CostCentres valid and active ?

5. Unit Price must be Positive

6. etc

Regards

Edy

Former Member
0 Kudos

Hi Sir. I'd like to capture all the line error before posting so that the user will be able to correct and upload it easily when error occured.. Sir I will try the XML thanks.

former_member183373
Active Participant
0 Kudos

Hi Phoenix,

I am not sure if this applies to your case but If you want to see whether a line is going to throw an error when you Add/Update it you can use Transaction method. This way you will see the validation error as mentioned. And you will also be able to rollback the transaction if operation succeeds.

You can check StartTransaction Method in the SDK Help file for more information.

Kind Regards,

Atilla