cancel
Showing results for 
Search instead for 
Did you mean: 

OWHS and OIGN table relationship

0 Kudos

Hey guys!

I'm doing a query and crashed in a list of tables.
When I use OWHS, the query returns nothing. When I remove the same OWHS table it works normally.
I tried to change OING to ING1, but the error still persists.

I need a light!

T4."DocDate", T2."WhsCode", T3."WhsName", T0."ItmsGrpNam", T1."ItemCode", T1."ItemName", T1."InvntryUom", T2."OnHand", T1."U_RSD_PesoBruto", T1."U_RSD_UN_Conversao", T2."AvgPrice" 


FROM  OITB T0  
INNER  JOIN OITM T1  ON  T1."ItmsGrpCod" = T0."ItmsGrpCod"   
INNER  JOIN OITW T2  ON  T2."ItemCode" = T1."ItemCode"   
INNER  JOIN OWHS T3  ON  T3."WhsCode" = T2."WhsCode"   
INNER  JOIN OIGN T4  ON  T4."Filler" = T3."WhsCode"  AND  T4."ToWhsCode" = T3."WhsCode"   

WHERE 

T4."DocDate" >= [%0] 

Thankful right now!

Accepted Solutions (1)

Accepted Solutions (1)

mgregur
Active Contributor

Hi,

I suggest using IGN1 as Items (and respective Warehouse) are on Document lines and not Header. use the following joins:

FROM IGN1 T0
INNE JOIN OIGN T1 ON T0."DocEntry" = T1."DocEntry"
INNER JOIN OITM T2 ON T0."ItemCode" = T2."ItemCode"
INNER JOIN OITB T3 ON T2."ItmsGrpCod" = T3."ItmsGrpCod"
INNER JOIN OITW T4 ON T0."ItemCode" = T4."ItemCode" AND T0."WhsCode" = T4."WhsCode"
INNER JOIN OWHS T5 ON T0."WhsCode" = T5."WhsCode"
WHERE T1."DocDate" >= [%0]

BR,

Matija

0 Kudos

How are you, Matija Gregur?

With this guidance, the code was really successful.
Analyzing, I saw a new need that is to launch OINV (INV1) and OPCH (PCH1) launches.

Inserting both in the code again, the returned value is empty.

See below:

T1."DocDate", T6."DocDate", T7."DocDate", T0."WhsCode", T5."WhsName", T3."ItmsGrpNam", T0."ItemCode", T2."ItemName", T2."InvntryUom", T4."OnHand", T2."U_RSD_PesoBruto", T2."U_RSD_UN_Conversao", T4."AvgPrice"
FROM IGN1 T0
INNER JOIN OIGN T1 ON T0."DocEntry" = T1."DocEntry"
INNER JOIN OITM T2 ON T0."ItemCode" = T2."ItemCode"
INNER JOIN OITB T3 ON T2."ItmsGrpCod" = T3."ItmsGrpCod"
INNER JOIN OITW T4 ON T0."ItemCode" = T4."ItemCode" AND T0."WhsCode" = T4."WhsCode"
INNER JOIN OWHS T5 ON T0."WhsCode" = T5."WhsCode"

--INNER JOIN OINV T6 ON  T6."Filler" = T5."WhsCode"  AND  T6."ToWhsCode" = T5."WhsCode"  
--INNER JOIN OPCH T7 ON  T7."Filler" = T5."WhsCode"  AND  T7."ToWhsCode" = T5."WhsCode"

WHERE 
T1."DocDate" >= [%0] AND
T0."ItemCode" = [%1]<br>

Is it possible to relocate with these tables as well?
I always miss this syntax.

Regards,

mgregur
Active Contributor

Hi,

do you mean creating a different SELECT with OINV and OPCH? If so, just replace IGN1 with INV1 / PCH1, and OIGN with OINV / OPCH and it should work.

The join you used in the above example is definitely not going to work because

a) you're using Header tables, and not lines

b) you're joining simply by Warehouse (which will give you wrong data).

What is the point of these joins? What are you exactly trying to achieve?

BR,

Matija

0 Kudos

Hi,

I will try to make the changes.

What I want to achieve is all the entries (Launches) in the OIGN, OINV and OPCH tables. With that I will have an accumulated result of the product, and this is for the purpose of inventory.

Therefore, I think the launch dates for OING, OIVN and OPCH could be accessed with the item in the OITM table.
I understood when I said: "a) you're using Header tables, and not lines".
As a beginner, I still make some simple mistakes. (Laughs)

Regards,

0 Kudos

For now my query looks like this:


CASE WHEN T4."WhsCode" in (01,10,11,110,12,13,14,15,16,17) THEN 'AA - AAAA' WHEN T4."WhsCode" in (20,21,210,22,23,24,25,26,27) THEN 'BB - BBBB' WHEN T4."WhsCode" in (30,31,310,32,33,34,35,36,37) THEN 'CC - CCCC' WHEN T4."WhsCode" in (40,41,410,42,43,44,45,46,47,48) THEN 'DD - DDDD' END AS "Filial", T1."DocDate", T0."WhsCode", T5."WhsName", T3."ItmsGrpNam", T0."ItemCode", T2."ItemName", T2."InvntryUom", T4."OnHand", T2."U_RSD_PesoBruto", T2."U_RSD_UN_Conversao", T4."AvgPrice", (T4."AvgPrice" * T4."OnHand") as "Total_Acumulado" FROM IGN1 T0 INNER JOIN OIGN T1 ON T0."DocEntry" = T1."DocEntry" INNER JOIN OITM T2 ON T0."ItemCode" = T2."ItemCode" INNER JOIN OITB T3 ON T2."ItmsGrpCod" = T3."ItmsGrpCod" INNER JOIN OITW T4 ON T0."ItemCode" = T4."ItemCode" AND T0."WhsCode" = T4."WhsCode" INNER JOIN OWHS T5 ON T0."WhsCode" = T5."WhsCode" --INNER JOIN OINV T6 ON T6."Filler" = T0."ItemCode" AND T6."ToWhsCode" = T5."WhsCode" --INNER JOIN OPCH T7 ON T7."Filler" = T0."ItemCode" AND T7."ToWhsCode" = T5."WhsCode" WHERE T1."DocDate" >= [%0] AND T0."ItemCode" = [%1]

I now need to bring OINV and OPCH data.

Regards,

0 Kudos

Hi,

I made the following change, and the query even executes, but returns empty values.

FROM IGN1 T0

INNER JOIN OIGN T1 ON T0."DocEntry" = T1."DocEntry"
INNER JOIN OITM T2 ON T0."ItemCode" = T2."ItemCode"
INNER JOIN OITB T3 ON T2."ItmsGrpCod" = T3."ItmsGrpCod"
INNER JOIN OITW T4 ON T0."ItemCode" = T4."ItemCode" AND T0."WhsCode" = T4."WhsCode"
INNER JOIN OWHS T5 ON T0."WhsCode" = T5."WhsCode", INV1 T6
INNER JOIN OINV T7 ON T6."DocEntry" = T7."DocEntry", PCH1 T8
INNER JOIN OPCH T9 ON T8."DocEntry" = T9."DocEntry"

WHERE 

T1."DocDate" >= [%0] AND
T0."ItemCode" = [%1]

when I put another item in the query, SAP crashes.

I believe it is because of the OINV and OPCH tables that are open.

Answers (2)

Answers (2)

MD1
Active Contributor

please provide report format as you want /require

0 Kudos

Hi,
How are you, Mohd?
I can get the information using the OINM table, but my problem now is that the query brings several duplicate lines.
Do you have any tips how can I solve this?

T2."TransType",T2."DocDate", T2."InQty", T2."OutQty", T4."WhsCode", T3."WhsName" AS "Nome do depósito", T1."ItemCode", T1."ItemName", T0."ItmsGrpNam", T1."InvntryUom", T1."U_RSD_PesoBruto", T1."U_RSD_UN_Conversao", T4."AvgPrice" 

FROM  OITB T0  
INNER  JOIN OITM T1  ON  T1."ItmsGrpCod" = T0."ItmsGrpCod"   
INNER  JOIN OINM T2  ON  T2."ItemCode" = T1."ItemCode"   
INNER  JOIN OWHS T3  ON  T3."WhsCode" = T2."Warehouse"   
INNER  JOIN OITW T4  ON  T4."WhsCode" = T3."WhsCode"   
INNER  JOIN OITM T5  ON  T5."ItemCode" = T4."ItemCode"   

WHERE 
T2."TransType" in (59,20) AND
T1."ItemCode" = [%0]

I tried to limit in the OINM by the field "TransType (" 59, 20), but even so there are several duplicate lines and with that making it difficult to extract the information.


Regards,

Junior

MD1
Active Contributor
0 Kudos

can you explain , what is the requirement

0 Kudos

Hi Mohd Danish,

At OIGN I need all incoming entries by period (T4. "DocDate") or by item (T1. "ItemCode"). The link I need at OWHS is only in the field (T5. "WhsCode").
If I remove the OWHS table, the query is successfully executed, but it is incomplete.

Regards,