cancel
Showing results for 
Search instead for 
Did you mean: 

Updating Ref2 in Journal Entry when NumAtCard field in A/R invoice is changed

cholae
Explorer
0 Kudos
738

Hi,

I would like to know for updating ref2 in journal entry when I update the NumAtCard field in A/R invoice.

My problem is

when I update NumAtCard in A/R invoice, didn't update Ref2 field in journal entry.

I also want to update there.

Please advise me how I should do.

Thanks.

Abdul
Active Contributor
0 Kudos

If your problem is solved please mark helpful answer and close the thread

Accepted Solutions (0)

Answers (4)

Answers (4)

cholae
Explorer
0 Kudos

Thanks, I have solved as follow. Now it's working fine.

IF (@object_type in (13,14) and @transaction_type in (N'A',N'U'))

BEGIN

Update OJDT set Ref2 = T0.NumAtCard

From OINV T0 inner join OJDT T1 on T0.DocEntry = T1.BaseRef

Update OJDT set Ref2 = T0.NumAtCard

From ORIN T0 inner join OJDT T1 on T0.DocEntry = T1.BaseRef

End

Abdul
Active Contributor
0 Kudos

You can update by standard B1 feature go to administration and reference field links select your marketing document and it will show you mapping and configure mapping rule for Customer/Vendor reference to ref2 in JE. See the below image you will understand.

Avoid using update queries as by using such queries you may loose support from SAP as per SAP's support policy.

cholae
Explorer
0 Kudos

Ok,Thanks for your suggestion.

former_member225732
Contributor
0 Kudos

Dear

Below just an example, you modify as per your requirement and hope you know SQL:

IF ((@object_type = N'13' ) and @transaction_type in (N'A',N'U'))

BEGIN

DECLARE @ExciseNum NVARCHAR(1000)

SELECT@ExciseNum=COALESCE(@ExciseNum+ ',','') + ISNULL(Cast(A.DocNum as Nvarchar(100)),'') FROM( select Distinct T5.DocNum From OINV T0

LEFT OUTER JOIN INV1 T1 ON T0.DocEntry = t1.docentry

LEFT OUTER JOIN DLN1 t2 on T1.BaseEntry = T2.DocEntry and T1.BaseType = t2.ObjType and T1.BaseLine = t2.LineNum

Left Outer Join ODLN T3 on t3.DocEntry = t2.DocEntry Left Outer Join OEI1 T4 on t4.BaseEntry = t3.DocEntry and t4.BaseLine = t2.LineNum and t2.ObjType = t4.BaseType

Left Outer Join OOEI T5 on T4.DocEntry = T5.DocEntry WHERE

T0.DocEntry=@list_of_cols_val_tab_del )A

UPDATET4 SETT4.U_OEINo = @ExciseNum FROMOINV T4 WHERET4.DocEntry = @list_of_cols_val_tab_del

END

cholae
Explorer
0 Kudos

Dear,

I tried as follow. But fail. Guide me,please.

If ((@object_type = N'13') and @transaction_type in (N'A',N'U'))

BEGIN

DECLARE @RefNum NVARCHAR(100)

Set @RefNum = (select COALESCE(@RefNum+ ',','') + ISNULL(Cast(A.NumAtCard as Nvarchar(100)),'')

from (select T0.NumAtCard from OINV T0 inner join OJDT T1 On T0.TransId = T1.TransId

where T0.TransId = @list_of_cols_val_tab_del)A)

Update OJDT Set OJDT.Ref2 = @RefNum where OJDT.TransId = @list_of_cols_val_tab_del

former_member225732
Contributor
0 Kudos

Dear Eve Lim,

Please try with Post transaction Notification.

Best Regards,
Sandesh Shinde

cholae
Explorer
0 Kudos

Thanks your reply and can you provide me any reference to write query, please?

I think still something wrong in query. That's why.