How to code this logic?
I have an internal table with two fields FLD1 & FLD2(flag). I have to make sure that for same FLD1, there has to be only one FLD2 flag:
FLD1 FLD2
A X
A
B X
B X
B
For example in the above example, 'B' has two 'X' therefore, I have to give an error message saying " Maintain only one 'X' value for B"
How do I do this?
Thanks
Sg
try the code given below. It may help to code occording to ur desired logic.
DATA: BEGIN OF it OCCURS 10,
fld1 TYPE c,
fld2 TYPE c,
END OF it.
PARAMETERS: pfld1 type c .
pfld2 type c.
data temp type i.
start-of-SELECTION.
loop at it.
if it-fld1 = pfld1 and it-fld2 = pfld2.
temp = 1.
STOP.
endif.
ENDLOOP.
end-of-SELECTION.
if temp = 0.
it-fld1 = pfld1. it-fld2 = pfld2.
append it.
write: / 'data append'.
sort it by fld1.
loop at it.
write: / it-fld1, it-fld2.
ENDLOOP.
else.
WRITE / 'Maintain only one',pfld2, 'value for',pfld1.
it-fld1 = pfld1. it-fld2 = ''.
APPEND it.
sort it by fld1.
loop at it.
write: / it-fld1, it-fld2.
ENDLOOP.
endif.
regards
Vijaykumar Reddy. S
Similar Messages
-
In this report i have marked one line..if this width < 30,i need to multiply by a number 0.3 and if the width >=30,it multiplies by 0.37...how to use this logic here..??? anyone can help??
Declare @FromDate Datetime
Declare @ToDate Datetime
Declare @SCCode nvarchar(30)
select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]'
select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]'
--Rcpt from PRDN (Condition checked for Return component exclusion also)
SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,
T2.DocNum AS 'WorkOrderNo',
b.DocNum as 'Issue Doc No',
ISNULL(d.DocNum,'') as 'Receipt Doc No',
b.U_IssPSCName as 'SubContractor Name',
T2.ItemCode as 'FG Item Code',
T3.ItemName as 'FG Item Name',
T2.PlannedQty as 'FG Planned Qty',
T2.U_OD as 'OD',
T2.U_ID as 'ID',
T2.U_OD/25.4 as 'Inches',
(T2.U_OD-T2.U_ID)/2 as 'Width',
0 as 'FG Pending Qty',
0 as 'FG Receipt Qty',
'' as 'Issue Item Code',
'' as 'Issue Item Name',
Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',
0 as 'Issue Item - Return Quantity',
'' as 'Return Doc No',
SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',
SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'
from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntry
INNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCode
LEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode not in (a.ItemCode)
LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode INNER JOIN OIGN d on c.DocEntry = d.DocEntry
WHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'
GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,T2.PlannedQty,T2.U_OD,T2.U_ID, T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2
UNION ALL
SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,
T2.DocNum AS 'WorkOrderNo',
b.DocNum as 'Issue Doc No',
ISNULL(d.DocNum,'') as 'Receipt Doc No',
b.U_IssPSCName as 'SubContractor Name',
T2.ItemCode as 'Item Code',
T3.ItemName as 'Item Name',
T2.PlannedQty as 'Planned Qty',
T2.U_OD as 'OD',
T2.U_ID as 'ID',
T2.U_OD/25.4 as 'Inches',
(T2.U_OD-T2.U_ID)/2 as 'Width',
(Select (T2.PlannedQty - (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum))) as 'Pending Qty',
(Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum) as 'Receipt Qty',
a.ItemCode as 'Issued Item Code',
a.Dscription as 'Issued Item Name',
Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',
(Select (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode))) as 'Issue Item - Return Quantity',
(ISNULL((Select (Select a2.DocNum from OIGN a2 where a2.DocEntry = a1.DocEntry) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode)),'')) as 'Return Doc No',
SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',
SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'
from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntry
INNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCode
LEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode in (a.ItemCode)
LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode LEFT JOIN OIGN d on c.DocEntry = d.DocEntry
WHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'
GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,T2.PlannedQty,T2.U_OD,T2.U_ID,T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2,a.ItemCode,a.Dscription order by T2.DocNum descHi,
Try this:
Declare @FromDate Datetime
Declare @ToDate Datetime
Declare @SCCode nvarchar(30)
select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]'
select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]'
--Rcpt from PRDN (Condition checked for Return component exclusion also)
SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,
T2.DocNum AS 'WorkOrderNo',
b.DocNum as 'Issue Doc No',
ISNULL(d.DocNum,'') as 'Receipt Doc No',
b.U_IssPSCName as 'SubContractor Name',
T2.ItemCode as 'FG Item Code',T3.ItemName as 'FG Item Name',T2.PlannedQty as 'FG Planned Qty',T2.U_OD as 'OD',T2.U_ID as 'ID',T2.U_OD/25.4 as 'Inches',(T2.U_OD-T2.U_ID)/2 as 'Width',case when ((T2.U_OD-T2.U_ID)/2) <30 then ((T2.U_OD-T2.U_ID)/2) *0.3 end, 0 as 'FG Pending Qty',0 as 'FG Receipt Qty','' as 'Issue Item Code','' as 'Issue Item Name',Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',0 as 'Issue Item - Return Quantity','' as 'Return Doc No',SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntryINNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCodeLEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode not in (a.ItemCode)LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode INNER JOIN OIGN d on c.DocEntry = d.DocEntryWHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,T2.PlannedQty,T2.U_OD,T2.U_ID, T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2UNION ALL SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,T2.DocNum AS 'WorkOrderNo',
b.DocNum as 'Issue Doc No',
ISNULL(d.DocNum,'') as 'Receipt Doc No',
b.U_IssPSCName as 'SubContractor Name',
T2.ItemCode as 'Item Code',T3.ItemName as 'Item Name',T2.PlannedQty as 'Planned Qty',T2.U_OD as 'OD',T2.U_ID as 'ID',T2.U_OD/25.4 as 'Inches',(T2.U_OD-T2.U_ID)/2 as 'Width',case when ((T2.U_OD-T2.U_ID)/2) >=30 then ((T2.U_OD-T2.U_ID)/2) *0.37 end, (Select (T2.PlannedQty - (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum))) as 'Pending Qty',(Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum) as 'Receipt Qty',
a.ItemCode as 'Issued Item Code',
a.Dscription as 'Issued Item Name',
Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',
(Select (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry
where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode))) as 'Issue Item - Return Quantity',
(ISNULL((Select (Select a2.DocNum from OIGN a2 where a2.DocEntry = a1.DocEntry) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode)),'')) as 'Return Doc No',
SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',
SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'
from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntry
INNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCode
LEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode in (a.ItemCode)
LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode LEFT JOIN OIGN d on c.DocEntry = d.DocEntry
WHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'
GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,
T2.PlannedQty,T2.U_OD,
T2.U_ID,T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2,a.ItemCode,a.Dscription
order by T2.DocNum desc
Thanks & Regards,
Nagarajan -
How to Code "AND" logic in Update Rule?
Hi:
I have minimal ABAP knowledge and need some help....
I have to use the Query logic and code in my Update rule... (i.e. multiple conditions have to be met)
IF (COMM_STRUCTURE-Sales_Org = '100' AND COMM_Structure-Division = 'LA' AND COMM_STRUCTURE-Acct_Grp = '0120')
RESULT = COMM_STRUCTURE-Credit_Amoutn (I want to assign a specific KF)
ELSE
RESULT = 0 (I want to assign Zero)
ENDIF
I attempted this logic, but I keep getting an error with 'AND' statement. I am not sure what is the syntax.
Can someone please help me out with the logic/sytax
Thanks..... LeeHi:
I responded without checking the logic.... assuming it would work...!~
Unfortunately it gives me error:
QUOTE
E:Incorrect logical expression: ")" must be followed by "AND" or "OR" . .
UNQUOTE
Can anyone help me resolving this please....!!!!
Thanks... lee -
How to code this...please help
Hi Friends:
Please help me in coding the following scenario:
I've the following checkboxes on selection screen:
1. inventory quantity current period-unrestricted (mard-labst)
2. inventory quantity current period-restricted use stock (mard-einme)
3. inventory quantity current period-in quality inspection(mard-insme)
4. inventory quantity current period - blocked (mard-speme)
5. inventory quantity current period - returns (mard-retme)
6. inventory quantity current period- stock in transfer (mard-umlme)
now the scenario is like this. The user may check 1/2/3/4/5/6 checkboxes while executing this program. Now what all checkboxes are checked, only those values to be fetched from MARD. E.g. 1 & 2 are checked. Then I'll fetch labst & einme from MARD. Then I'll add it up. Please help me in coidng this. How to decide it at runtime.
Thanks:Hi use this logic.
if c1 = 'X.
select single labst from mard into corrseponding table it_mard where..
endif
if c2 = 'X.
select single einme from mard into corrseponding table it_mard where..
endif.
if c3 = 'X.
select single insmefrom mard into corrseponding table it_mard where..
endif.
if c4 = 'X.
select single spemefrom mard into corrseponding table it_mard where..endif.
endif
if c5 = 'X.
select single retme from mard into corrseponding table it_mard where..
endif.
if c6 = 'X.
select single umlme from mard into corrseponding table it_mard where..endif.
endif
Regards,
Prasad. -
Hi All,
Our application development will need to come up with a solution to update table B and tables C whenever a value in table A is changed to a certain value. Since I am new to Oracle stored procedures, I would like get some help on this. Can someone advice as to how to code the following? I greatly appreciate your ideas. Thanks!
Scenario:
Whenever the value on the column DCMTN_RCPT_STUS_CD is changed to "C" for table supplier_documentation (Table A), the value on the column BID_STUS_CD for table dmepos_bid will need to be updated to "01" (Table B), at the same time the column on BID_STUS_CD for supplier_application (Table C) will also
need to be updated to "01".
Table A:
SQL> select SUPLR_ID, BIDDER_NUM, NSC_NUM, DCMTN_RCPT_STUS_CD from
supplier_documentation where DCMTN_RCPT_STUS_CD='C';
BIDDER_NUM DCMTN_RCPT_STUS_CD
1000000 C
1000003 C
Table B:
SQL>select BIDDER_NUM, BID_STUS_CD from dmepos_bid order by bidder_num;
BIDDER_NUM BID_STUS_C
1000000
1000003
Table C:
SQL> select BIDDER_NUM, APLCTN_STUS_CD from supplier_application;
BIDDER_NUM APLCTN_STUS_CD
1000000
1000003See Oracle row-level triggers:
http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg13trg.htm#376
SQL> create or replace trigger tr_01
2 after update of DCMTN_RCPT_STUS_CD on supplier_documentation
3 for each row
4 when (new.DCMTN_RCPT_STUS_CD = 'C')
5 begin
6 update dmepos_bid set BID_STUS_C = :new.DCMTN_RCPT_STUS_CD
7 where BIDDER_NUM = :new.BIDDER_NUM;
8 update supplier_application set BID_STUS_C = :new.DCMTN_RCPT_STUS_CD
9 where BIDDER_NUM = :new.BIDDER_NUM;
10 end;
11 /
Trigger created.
SQL> select * from supplier_documentation;
BIDDER_NUM DC
1000000
1000003
SQL> select * from dmepos_bid;
BIDDER_NUM BI
1000000
1000003
SQL> select * from supplier_application;
BIDDER_NUM BI
1000000
1000003
SQL> update supplier_documentation set DCMTN_RCPT_STUS_CD = 'B'
2 where BIDDER_NUM = 1000000;
1 row updated.
SQL> select * from supplier_documentation;
BIDDER_NUM DC
1000000 B
1000003
SQL> select * from dmepos_bid;
BIDDER_NUM BI
1000000
1000003
SQL> select * from supplier_application;
BIDDER_NUM BI
1000000
1000003
SQL> update supplier_documentation set DCMTN_RCPT_STUS_CD = 'C'
2 where BIDDER_NUM = 1000000;
1 row updated.
SQL> select * from supplier_documentation;
BIDDER_NUM DC
1000000 C
1000003
SQL> select * from dmepos_bid;
BIDDER_NUM BI
1000000 C
1000003
SQL> select * from supplier_application;
BIDDER_NUM BI
1000000 C
1000003Rgds. -
Please try to code the following:
1. If payment end date (PA0014-ENDDA ) = '12.13.9999' (Delimited) AND 1st Payment date (PA0014-ZDATE) < Sept.01 of the current fiscal year.
2. ELSEIf payment end date (PA0014-ENDDA ) = '12.13.9999' (Delimited) AND 1st Payment date (PA0014-ZDATE) > Aug 31 of the current fiscal year.
3. ELSEIf payment end date (PA0014-ENDDA ) <> '12.13.9999' (Delimited) AND 1st Payment date (PA0014-ZDATE) > Aug31.
4. ELSEIf payment end date (PA0014-ENDDA ) <> '12.13.9999' (Delimited) AND 1st Payment date (PA0014-ZDATE) < Sept.01 of the current fiscal year.
5. ELSE.
EXIT.
ENDIF.
NOTE: I have a problem on how you can determine if that particular date lies on that particular fiscal year or not. Please help me code this one.
II. This are conditions between of each code.
PAYMENT DATE is a variable should be used to store each successive payments.
For Scenario 1, set (PAYMENT DATE ) = 1st payment date occuring after Aug 31 (Fiscal YEar)
For Scenario 2, set (PAYMENT DATE ) = 1st payment date (SCREEN field: P0014-ZDATE)
For Scenario 3, set (PAYMENT DATE ) = 1st payment date (SCREEN field: P0014-ZDATE)
For Scenario 4, set (PAYMENT DATE ) = 1st payment date occuring after Aug 31 (Fiscal YEar)
IF the [Payment date] is <= to the infotype 0014 record end date (PA0014-ENDDA), do
If the [Payment date] is in between the start and end date of the current Fiscal year
If the unit (PA0014-ZEINH) is Days,
[Payment date] = [Payment date] + (# of days)
Add recurring payment (PA0014-BETRG) to total compensation counter
Endif
If the unit (PA0014-ZEINH) is Weeks, then {
[Payment date] = [Payment date] + (# of weeks)
Add recurring payment (PA0014-BETRG) to total compensationcounter
Endif
If the unit (PA0014-ZEINH) is Months, then {
[Payment date] = [Payment date] + (# of months)
Add recurring payment (PA0014-BETRG) to total compensation counter
Endif
If the unit (PA0014-ZEINH) is Years, then {
[Payment date] = [Payment date] + (# of years)
Add recurring payment (PA0014-BETRG) to total compensation counter
Endif
Endif
Endif
Repeat for next payment
Repeat for the next infotype 0014 record (if it exists)
I really need help! So guys whos expert in SAP. Thanx in Advance.>
Dave Packard wrote:
> Good day, everyone!
> I would like to join the tables FMIFIIT and AUFK. The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
>
> The problem I'm having is this: All of the values in AUFNR are preceeded by two zeros. For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'. Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
> Dave
You can't do a join like this in SAP's open SQL. You could do it in real SQL ie EXEC.... ENDEXEC by using SUSBTR to strip off the leading zeros from AUFNR but this would not be a good idea because a) modifying a column in the WHERE clause will stop any index on that column being used and b) using real SQL rather than open SQL is really not something that should be encouraged for database portability reasons etc.
Forget about a database join and do it in two stages; get your AUFK data into an itab, strip off the leading zeros, and then use FAE to get the FMIFIIT data (or do it the other way round).
I do hope you've got an index on your FMIFIIT MEASURE field (we don't have one here); otherwise your SELECT could be slow if the table holds a lot of data. -
How to code this - Please advise
Dear friends,
Please advise as how to code the below scenario in order to obtain the best performance.
I've an internal table IT_BSAD.Now I've to check if in the combination of bukrs,augbl,auggj,kostl,prctr,gsber,aufnr, if there is a single record in IT_BSAD, then it should be appended to IT_BSAD1 & if there are multiple records, then those should be appended to IT_BSAD2. In any case IT_BSAD1 & IT_BSAD2 should not contain duplicate records & records in IT_BSAD = records in IT_BSAD1 + Records in IT_BSAD2. I coded it somehow but it hangs in case of million of records. Please advise me the best way of doing it.
I'll appreciate any help in this regard.
Thanks:
Gauravprepare a sorted table with key bukrs,augbl,auggj,kostl,prctr,gsber,aufnr
loop it_basd assigning <fs_basd> .
at new sufnr.
lv_index = 0.
endat.
" move the fields to it_basd1 work area
"append it_basd1
lv_index = lv_index + 1.
if lv_index > 1.
if lv_index = 2.
read it_basd1 into iwa_basd2 with key bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.
append iwa_bsad2 into it_bsad2.
delete from it_basd1 where bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.
endif.
" move the fields of <fs_basd> to it_basd2 work area
append iwa_bsad2 into it_bsad2.
endif.
endloop.
hope this will help
Nafran -
Need help on how to code this SQL statement! (one key has leading zeros)
Good day, everyone!
First of all, I apologize if this isn't the best forum. I thought of putting it in the SAP Oracle database forum, but the messages there seemed to be geared outside of ABAP SELECTs and programming. Here's my question:
I would like to join the tables FMIFIIT and AUFK. The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
The problem I'm having is this: All of the values in AUFNR are preceeded by two zeros. For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'. Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
Unfortunately, I don't have a lot of experience coding SQL, so I'm not sure how to resolve this.
Please help! As always, I will award points to ALL helpful responses!
Thanks!!
Dave>
Dave Packard wrote:
> Good day, everyone!
> I would like to join the tables FMIFIIT and AUFK. The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
>
> The problem I'm having is this: All of the values in AUFNR are preceeded by two zeros. For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'. Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
> Dave
You can't do a join like this in SAP's open SQL. You could do it in real SQL ie EXEC.... ENDEXEC by using SUSBTR to strip off the leading zeros from AUFNR but this would not be a good idea because a) modifying a column in the WHERE clause will stop any index on that column being used and b) using real SQL rather than open SQL is really not something that should be encouraged for database portability reasons etc.
Forget about a database join and do it in two stages; get your AUFK data into an itab, strip off the leading zeros, and then use FAE to get the FMIFIIT data (or do it the other way round).
I do hope you've got an index on your FMIFIIT MEASURE field (we don't have one here); otherwise your SELECT could be slow if the table holds a lot of data. -
Hello, I'm using Access and need to code this query on SQL and I have this problem:
I have 3 tables: Movie, Actor, Acts_In
Movie table has fields: Movie_ID, movie_name, actor_1, actor_2, director
Actor table has fields: Actor_ID, first_name, last_name
Acts_IN table has fields: Movie_ID, Actor_ID
* actor_id and movie_id are primary keys
I have to create a query that allows me to search for a director, giving me a list of actors that have worked with that director, and all the movies they have acted in.
so far I have come up with this code, however:
select actor.first_name, actor.last_name, movie_name
from (actor inner join acts_in ON acts_in.actor_ID=actor.actor_id) inner JOIN movie
ON acts_in.movie_ID=movie.movie_id
group by actor.first_name, actor.last_name, movie_name;
This code gives me a list of all actors and all movies they acted in, but it does not give me specific actors in respect to a specific director, adding
where director="XYZ"
does not work as it gives me all actors that have worked with director XYZ but not all movies they have acted in.
Thanks!Grump. You should have provided us example data and DML, like this:
DECLARE @movies TABLE (movie_ID INT, movie_Name VARCHAR(50), director VARCHAR(75))
DECLARE @actors TABLE (actor_ID INT, first_name VARCHAR(50), last_name VARCHAR(50))
DECLARE @acts_in TABLE (movie_ID INT, actor_ID INT)
INSERT INTO @movies (movie_ID, movie_Name, director) VALUES
(1, 'Batman Returns', 'Tim Burton'),
(2, 'Charlie and the Chocolate Factory', 'Tim Burton'),
(3, 'Sweeney Todd', 'Tim Burton'),
(4, 'Alice in Wonderland', 'Tim Burton'),
(5, 'Edward Scissor Hands', 'Tim Burton'),
(6, 'From Hell', 'Albert Huges')
INSERT INTO @actors (actor_ID, first_name, last_name) VALUES
(1, 'Danny', 'DeVito'),
(2, 'Freddie', 'Highmore'),
(3, 'Helena', 'Bonham-Carter'),
(4, 'Johnny', 'Depp'),
(5, 'Mia', 'Wasikowska'),
(6, 'Micheal', 'Keaton'),
(7, 'Winona', 'Ryder')
INSERT INTO @acts_in (movie_id, actor_ID) VALUES
(1, 1),(1, 6),
(2, 2),(2, 4),
(3, 3),(3, 4),
(4, 4),(4, 5),
(5, 4),(5, 7),
(6, 4)
Which would have allowed us to come up with this:
SELECT m2.director, a.first_name, a.last_name, m2.movie_Name
FROM ((((@movies m
INNER JOIN @acts_in ai
ON m.movie_ID = ai.movie_ID)
INNER JOIN @actors a
ON ai.actor_ID = a.actor_ID)
INNER JOIN @acts_in ai2
ON a.actor_ID = ai2.actor_ID)
INNER JOIN @movies m2
ON ai2.movie_ID = m2.movie_ID)
WHERE m.director = 'Tim Burton'
GROUP BY m2.director, a.first_name, a.last_name, m2.movie_Name
IIRC the primary difference between TSQL and the "Access SQL" is the freakin parens. So that *should* run in access, which you appear to be using.
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question. -
How to code my logic in Search Help Exit
Hi,
I need to add my own Search Help say MATOG in Material MATNR Collective Search Help MAT1-> Collective Search help MAT1_A.
Is it possible?
And , when I need to add my own logic in Search Help exit for my particular Search Help, how should I code?
Thanks,
Shivaa..Hi,
Go through below link, it gives you step by step approach in implementing search help exit.
https://wiki.sdn.sap.com/wiki/display/Snippets/ImplementingSearchHelp+Exits
Regards,
Raghavendra -
How to write this logic in EL expression ? (new line characters in string
iam using JSTL EL expression in my JSP.
iam printing a string in JSP as ${vobject.rmessage} where rmessage is a string .
problem is i want to identify the newline characters in the above rmessage string and print the line break <br> in html where ever the new lines character is present in the string.
How should i write an EL expression for the above.
Can anyone please guide me on writing EL expression for the above problem?Several ways. You can wrap the output with <pre> tags. You can apply CSS property white-space: pre; to the element. You can use String#replaceAll() in the Java code to replace each occurence of "\r\n" by "<br>".
-
How to implement this logic in odi
suposse my table is like this
a b c
1234 01-JAN-09 0
1234 02-JAN-09 1
1234 05-JAN-09 1
1244 06-JAN-09 1
1234 10-JAN-09 0
1234 13-JAN-09 1
1234 25-JAN-09 0
1234 27-JAN-09 1
1234 30-JAN-09 1
1235 01-JAN-09 1
1235 02-JAN-09 0
1235 05-JAN-09 1
1245 06-JAN-09 1
1235 10-JAN-09 1
1235 13-JAN-09 3
1235 25-JAN-09 2
1235 27-JAN-09 0
1235 30-JAN-09 0
i want out put like this
a b c
1234 01-JAN-09 0
1234 02-JAN-09 1
1234 05-JAN-09 2
1244 06-JAN-09 3
1234 10-JAN-09 3
1234 13-JAN-09 4
1234 25-JAN-09 4
1234 27-JAN-09 5
1234 30-JAN-09 6
1235 01-JAN-09 1
1235 02-JAN-09 1
1235 05-JAN-09 2
1245 06-JAN-09 3
1235 10-JAN-09 4
1235 13-JAN-09 7
1235 25-JAN-09 9
1235 27-JAN-09 9
1235 30-JAN-09 9
to get out put like that iam using this query
select a,b,sum(c) over(partition by a order by b) from table.
how to implement "sum(c) over(partition by a order by b)" in odi interface mappingsHi
if you don't want to aggregate try to define a user function
analytic_sum($(value))
implémented by
sum($(value))
after that
replace your
sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)
by
analytic_sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row) -
How to code this : LE_SHIPMENT_BADI : method : At_Save
Hi Friends:
I'm working on LE_SHIPMENT_BADI. In the method At_Save, I've written the following code:
METHOD if_ex_badi_le_shipment~at_save.
This is just an additional check to ensure the following requirement:
If the ship-to-party begins with XX, then Shipment type should be 'ZSTO'.
If the ship-to-party doesn't begins with XX, then Shipment type should be '0001'.
CONSTANTS : c_zsto TYPE vttkvb-shtyp VALUE 'ZSTO', "Constant for shipment type ZSTO
c_0001 TYPE vttkvb-shtyp VALUE '0001', "Constant for shipment type 0001
c_xx(2) TYPE c VALUE 'XX'. "Constant for the first 2 characters of Ship-to-party
DATA : v_kunwe TYPE vtrlk-kunwe,
v_shp TYPE vttkvb-shtyp,
v_vttk TYPE vttkvb.
FIELD-SYMBOLS : <fs> TYPE vtrlk.
This provision is made if the internal table CHA_SHIPMENTS_AT_SAVE
is initial, which is generally not the case. If such case is observed
the the below mentioned code can be used.
*if CHA_SHIPMENTS_AT_SAVE is initial.
*CHA_SHIPMENTS_AT_SAVE = IM_shipments_AT_SAVE.
*endif.
READ TABLE cha_shipments_at_save-new_vtrlk ASSIGNING <fs> WITH KEY kunwe+0(2) = c_xx.
IF sy-subrc = 0.
v_shp = c_zsto.
ELSE.
v_shp = c_0001.
ENDIF.
v_vttk-shtyp = v_shp.
MODIFY cha_shipments_at_save-new_vttk
FROM v_vttk TRANSPORTING shtyp
WHERE shtyp <> v_shp.
ENDMETHOD
Now I have to put one more check in it. There is a field LFART in table VTRLK . I want the above coding to work only when LFART = LF, ZLF, LR and ZLR. Please help me in implementing this.
Suitable points will be Rewarded.
Regards:Hello,
If you have the values for LFART then simply check loke:
CHECK ( lfart = 'XX' or lfart = 'YY').
and here check for the other condition,
Regards,
Sandeep -
How to code this with serial communication?
Here's What I Want To Do.
There are two computers A and B. I send some variational data, 1.2,3.4 for example, from A to B once per second. If B has received the right data, he will send "Yes" to A, otherwise he will say "No". If received "Yes", A will get ready for the next data-sending. If "No", A will send the data again.
The examples with LabVIEW for VISA communication are all like that one computer is listening and the other one is writing all the time. So can you help me with two simple VIs for computer A and B?
Regards.You need to connect the two computers' serial ports with a Null Modem Cable (Tx/Rx, CTS/RTS, DTR/DCD reversed). The put the attached vi on computer A. It will send a command from an array, and wait for a response from computer B. If the response is Yes, then the next command will be sent. If not Yes then A will send the same command again and wait for a response. There is an Abort button if you want to abort, but it will only abort the current command. You can modify it to abort the whole thing by using a while loop to replace the for loop, and using the abort button to exit the while loop. I'll leave the coding up to you. You will have to write a vi to reside on B. I'll describe it but you can code it, good practice. Computer B should start off initializing the com port, like in the attached vi. Then loop at Bytes at Port until some bytes come in, then read the bytes. Use a comparison (equal) to check if the data is good. Use a case structure to define what to send back to computer A (Yes or No). Then write it back using Visa Write. Loop around the entire thing except for the com port init. Close the Visa after the main loop.
- tbob
Inventor of the WORM Global
Attachments:
COM_AtoB.vi 50 KB -
How to code this using FIELD SYMBOL ?
Hello All,
I never used field symbols before and I think this is where I should use field symbols in my program.
I have a selection parameter period (p_period) and based on the p_period value(XX), I need to display the HSLXX, KSLXX from table GLT0 using field symbols. Can anyboby help me?
Thanks,
Chandni ReddyRight, you can use field-symbols, here is a example.
report zrich_0002.
data: xGLT0 type GLT0 .
data: field_name(20) type c.
field-symbols: <fs> .
parameters: p_per(2) type n.
* Read a line from table
select Single * from glt0 into xglt0.
* Build the field name that you want to access
concatenate 'XGLT0-HSL' p_per into field_name.
* Assign it
assign (field_name) to <fs>.
* Write it
write:/ <fs>.
Regards,
Rich Heilman
Maybe you are looking for
-
My co-worker has given me his iPod to take home and transfer his music to my laptop, however, I am unable to access his music to download it to my computer. How does this work?
-
Hello! I'm in desperate need of a miracle here. I've already read over other solutions to this problem, but perhaps someone can come up with something I haven't. I'm using Final Cut Pro 7.0.3, and I finished a project last month that took a lot of ed
-
Best practice for tracking database changes...?
Dear Oracle gurus, I'm still relatively new to database administrating, and recently I ran into a situation which I'm not sure if there's some text-book scenario analysis or practice. I find it hard to track all the database changes across different
-
Adobe Photoshop Elements 2.0 re- installation.
Since my computer crashed and was rebooted, I have been unable to use my photoshop Elements 2.0. I have pressed the install icon but nothing happens. i have the original serial Number, is there a way of doing it now with out the disc? Was wondering i
-
Warning to people looking for a gaming laptop
I bought Gateway FX P-7805u(Core Duo 2 P8400, 4GB RAM, 17.1" monitor with 1920x1200 max res, and GeForce M 9800GTS 1GB for $1,150 ) about 10 days ago. It was an amazing deal! I searched the internet for hours and couldn't find a laptop that was a big