cancel
Showing results for 
Search instead for 
Did you mean: 

Sales order approval for above 50% discount on any item row level

Former Member
0 Kudos

Dear Experts,

I am having the requirement like if any of the row in sales order having above 50% discount then approval should triggered. I tried the following query but its returning only first row only. If any came across with solution? Please suggest solution.

SELECT MAX($[$38.15.0]) FROM DUMMY

Thanks & Regards

Karunakaran P.

Accepted Solutions (0)

Answers (4)

Answers (4)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Sorry late reply. I don't have HANA environment to test and advice.

1. Updating using stored procedure for UDF is not supported by SAP.

2. Approval procedure and Stored procedure will not work together.

Thanks

Former Member
0 Kudos

Dear Experts,

I created the Stored Procedure to update UDF for MAX(DiscPrcnt) in Row Level as following

if :object_type = '17' and (:transaction_type='A' or :transaction_type='U') then

     UPDATE ORDR SET ORDR."U_UDF" = (SELECT MAX(RDR1."DiscPrcnt") FROM RDR1      WHERE RDR1."DocEntry" = :list_of_cols_val_tab_del)

     FROM ORDR WHERE ORDR."DocEntry" = :list_of_cols_val_tab_del;

End if;

Its working fine.

Then I created Approval query as following

SELECT DISTINCT 'TRUE'

FROM ORDR T0

WHERE

$[ORDR."U_oerpno".Number] > 50

But Approval Procedure is not triggered while adding. In case of Duplicate approval is working fine.

As per my understanding Approval Procedure is triggering before store procedure update  the UDF.

Please correct me if am wrong. If any buddy having solution pls share it.

Thanks in Advance

Karunakaran P.

narayanis
Active Contributor
0 Kudos

Hi,

SPTN fires when DML statement hits the database. Before execution of DML statement, code written in SPTN fires if the conditions mentioned therein are satisfied then, DML is executed else rollback.

Where as approvals keep the document if draft mode and submits the transaction by flagging it.

Two things work completely on different principles.

Hi, Nagajan

Is it in SAP B1 9.0 onwards UDF updation is not possible. Because i've worked with 8 and 8.x where UDFs do get updated.

Regards

Narayani

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

If it is only one row, then it is possible to get approval. If multiple rows with different discount then approval will not work.

Alternatively you can go for Transaction notification.

Thanks

Former Member
0 Kudos

Dear Nagarajan,

Can you please help me in creating the SP Transaction Notification for HANA. My requirement is header level UDF field should update for MAX(Discount %) in row level.

Thanks in Advance

narayanis
Active Contributor
0 Kudos

Hi,

Declare @DiscPrcnt Decimal (16,2)

if @Objcet_type = '17' and Transaction_Type in ('A', 'U')

     Begin

          Select @retVal = max(RDR1.discprcnt) from RDR1 inner join ORDR on ORDR.docentry =           RDR1.DocEntry where ORDR.DocEntry = @list_of_cols_val_tab_del  and RDR1.discprcnt >           50

          if @DiscPrcnt >= 50 and @DiscPrcnt is not null

               Begin

                    Pass your update statement here

               End

     End

This will fetch maximum discount percentage at row level. Assign it to a variable @DiscPrcnt

If it is greater than or equal to 50 then updates the udf.

We are on SAP B1 9.1. Hope this will give you some idea to start your work.

Regards

Narayani

KennedyT21
Active Contributor
0 Kudos

Hi

Currently, you can't use an approval based on the trigger of the document line fields. It is current system definition of SAP B1. So, you can only use document header fields as trigger.


Cheers!

Former Member
0 Kudos

Dear Kennedy,

Yes you are correct, we cant do approval by document Line fields.

Actually i created one UDF in Header and writing FMS to get maximum of discount in row level.

Based on the UDF i m trying to trigger the approval.

Is it Possile?

KennedyT21
Active Contributor
0 Kudos

Yes It is Possible.

SELECT 'TRUE' 

FROM ORDR T0 

WHERE 

$[$ORDR.u_UDF1.Number] > 50 

You can use the above query for the approval.

Cheers!