Hope you are well. I need one help.
Currently I am trying to extraction information from the invoice . Currently there are many columns are extracted from pdf / invoices and exported into excel. I want to pass “only the invoice number column” from the excel file to the sql query .
“SELECT T1.[SYS_ID] as System_id
,T1.[ACC_DOC_NUM] as Doc_Num
,T1.[DOC_DATE] as Date
,T1.[REF_DOC_NUM] as Invoice
,T2.[PO_DOC_FX_VALUE] as TOTAL
,T2.[VENDOR_NO] as Vendor_No
,T3.VENDOR_NAME_1 as Vendor_Name
FROM [CACM_SAP].[dbo].[SAP_TFR_BKPF] T1
INNER JOIN [CACM_SAP].[dbo].[SAP_TFR_BSEG] T2 ON T1.SYS_ID=T2.SYS_ID AND T1.[ACC_DOC_NUM]=T2.[ACC_DOC_NUM] AND T1.[FISC_YEAR]=T2.[FISC_YEAR]
LEFT JOIN [CACM_SAP].[dbo].[SAP_TFR_LFA1] T3 ON T1.SYS_ID = T2.SYS_ID AND T2.VENDOR_NO = T3.VENDOR_NO
WHERE T2.VENDOR_NO =‘xxxxxxxxxx’
AND T1. Invoice = (Invoice no from the output of the invoice_extraction flow)
how can i do that please?
you mean something like this below please
“Select T1.[SYS_ID] As System_id
,T1.[ACC_DOC_NUM] As Doc_Num
,T1.[DOC_DATE] As Date
,T1.[REF_DOC_NUM] As Invoice
,T2.[PO_DOC_FX_VALUE] As TOTAL
,T2.[VENDOR_NO] As Vendor_No
,T3.VENDOR_NAME_1 As Vendor_Name
From [CACM_SAP].[dbo].[SAP_TFR_BKPF] T1
INNER Join [CACM_SAP].[dbo].[SAP_TFR_BSEG] T2 On T1.SYS_ID=T2.SYS_ID And T1.[ACC_DOC_NUM]=T2.[ACC_DOC_NUM] And T1.[FISC_YEAR]=T2.[FISC_YEAR]
LEFT Join [CACM_SAP].[dbo].[SAP_TFR_LFA1] T3 On T1.SYS_ID = T2.SYS_ID And T2.VENDOR_NO = T3.VENDOR_NO
Where T2.VENDOR_NO =‘0001009311’
AND T1. [REF_DOC_NUM] =‘str’”
so In the query if you want to search multiple values in a column we give as T1.[Columname] IN (‘A’,‘B’,‘C’) so if you join only by comma the values in str will be like A,B,C and what you wrote was “‘str’” (any way you have to join like this “'” + Str +“'”) which turns out to be ‘A,B,C’ not the expected one
So Join by (‘,’) which makes str as A’,‘B’,‘C and when you give "(’" + str + “')”(Even I gave it wrong in previous post with out plus) like this (‘A’,‘B’,‘C’)
So your final query would be
"Select T1.[SYS_ID] As System_id
,T1.[ACC_DOC_NUM] As Doc_Num
,T1.[DOC_DATE] As Date
,T1.[REF_DOC_NUM] As Invoice
,T2.[PO_DOC_FX_VALUE] As TOTAL
,T2.[VENDOR_NO] As Vendor_No
,T3.VENDOR_NAME_1 As Vendor_Name
From [CACM_SAP].[dbo].[SAP_TFR_BKPF] T1
INNER Join [CACM_SAP].[dbo].[SAP_TFR_BSEG] T2 On T1.SYS_ID=T2.SYS_ID And T1.[ACC_DOC_NUM]=T2.[ACC_DOC_NUM] And T1.[FISC_YEAR]=T2.[FISC_YEAR]
LEFT Join [CACM_SAP].[dbo].[SAP_TFR_LFA1] T3 On T1.SYS_ID = T2.SYS_ID And T2.VENDOR_NO = T3.VENDOR_NO
Where T2.VENDOR_NO =‘0001009311’
AND T1. [REF_DOC_NUM] =('" + str + "’)"
Apologies @Anil_G . Sorry for taking the name wrong.
Thank you so much for the kind reply and the help.
I will try to amend this and if stuck will get back to you on this please.
I believe you forgot to attache. Anyways… Please check the string that you gave properly. There is some issue there… because geneally when you give some string between double quotes in Advanced editor values turns little red unless something is wrong
If you have copy pasted the string please replace the inverted comma again in the code
I gave the same and i dont see any errors. if you have then it means you did something wrong and to see the error place the cursor in red exclamation and then the error would be visible