cancel
Showing results for 
Search instead for 
Did you mean: 

Query Generator SAP B1

0 Kudos

Hi,

We are using prefixes in numbering series while generating sales and purchasing documents, while I try to use the query generator to get some reports, how can I combine prefixes with a purchase order number???

Accepted Solutions (1)

Accepted Solutions (1)

former_member566317
Active Participant

Hi

Hope it will be helpful

Select CONCAT(TO_VARCHAR(IFNULL(T2."BeginStr",'')),TO_VARCHAR(T1."DocNum")) from OPOR T1 INNER JOIN NNM1 T2 ON T1."Series"=T2."Series" AND T1."ObjType"="ObjectCode" Where "DocEntry"=2

OR you can also use

Select TO_VARCHAR(IFNULL(T2."BeginStr",'')) ||TO_VARCHAR(T1."DocNum") from OPOR T1 INNER JOIN NNM1 T2 ON T1."Series"=T2."Series" AND T1."ObjType"="ObjectCode" Where "DocEntry"=2

Thanks,

0 Kudos

SELECT T0.[DocNum], T0.[CANCELED], T0.[DocStatus], T0.[DocDate], T0.[DocDueDate], T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[Price], T1.[LineTotal] FROM OPOR T0 INNER JOIN POR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

Please suggest how to combine it in the above query...

Regards

Answers (2)

Answers (2)

former_member566317
Active Participant

Hi

please use this one . Although I have used '-' between series Name and DocNum. if not required you can remove

SELECT (T2.[SeriesName]+'-'+CAST(T0.[DocNum] as varchar)) as [Document Number],T0.[DocNum], T0.[CANCELED], T0.[DocStatus], T0.[DocDate], T0.[DocDueDate], T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[Price], T1.[LineTotal] FROM OPOR T0 INNER JOIN POR1 T1 ON T0.[DocEntry] = T1.[DocEntry] LEFT OUTER JOIN NNM1 T2 ON T2.[Series]=T0.[Series] AND T2.[ObjectCode]=T0.[ObjType]

Johan_H
Active Contributor
0 Kudos

Hi,

You need the NNM1 table.

Regards,

Johan

0 Kudos

SELECT T0.[DocNum], T0.[CANCELED], T0.[DocStatus], T0.[DocDate], T0.[DocDueDate], T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[Price], T1.[LineTotal] FROM OPOR T0 INNER JOIN POR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

Please suggest how to combine it in the above query...

Regards