on 10-16-2014 7:36 AM
Hi All,
I have written the below code,
where:
Question: I am using CS(compare string) here to compare source system from
internal table and source package. Please let me know if this code works
properly.
Waiting for your inputs!! Thanks In Advance!!
LOOP AT SOURCE_PACKAGE ASSIGNING
<source_fields>
-----
-----
-----
Select * from zlookup into table itab.
Loop at itab into wtab.
If wtab-starttimestamp<=systimestamp and wtab-endtimestam>=systimestamp.
Delete source package where sourcesys cs wtab-source.
end if.
End loop.
---
----
End loop
Systimestamp = system current timestamp
Process chain ID | Sourcesys |
---|---|
PC1 | AAA,CCC |
PC2 | AAA,BBB |
PC3 | AAA,CCC |
PC4 | CCC |
PC5 | DDD |
PC6 | BBB |
Source | Starttimestamp | Endtimestamp |
---|---|---|
AAA | 20141016091626 | 20141016131626 |
BBB | 20141016091626 | 20141016151626 |
CCC |
Regards,
Roopa KS
You dont need the LOOP at SOURCE_PACKAGE.
Also, for performance reasons change the LOOP at itab thusly
Loop at itab into wtab where starttimestamp<=systimestamp and endtimestam>=systimestamp.
You can remove the IF statement within the LOOP AT
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Thanks for all your reply and help.
I have question where, my SAP system time is CET but system time is UTC.
I should compare time by converting UTC to CET right?
Please let me know!
Thanks and Regards,
Roopa KS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Depends. Please check what is the timestamp present in the ZLOOKUP table. The system/person that generates the entries of ZLOOKUP should be able to help you with that info.
If the ZLOOKUP timestamp is in UTC, you need to convert system time to UTC. If the ZLOOKUP is in CET and your system time is also CET, then no conversion is necessary.
Hi,
Please use below type of sample code, because it will take so much of time to execute the code if we write select statement in loop and endloop.
If there is a chance, please use for all entries functionality in your select statment.
Select * from zlookup into table itab.
LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>
-----
-----
read table itab into wtab with key wtab-starttimestamp<=systimestamp and wtab-endtimestam>=systimestamp.
if sy-subrc = 0.
Delete source package where sourcesys cs wtab-source.
endif.
End loop.
Regards,
Nagaraju K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roopa,
you cannot use "AND" in read statement, and in your scenario you want to check the fields like start time and end time with current day system time stamp. I am just giving a rough code in terms of Work Area .
loop at itab into wa. ----> which is Source Package.
loop at itab1 into wa1 where starttime = sy-uzeit and endtime = sy-uzeit.
if sy-subrc = 0.
delete itab where sourcesys EQ wa1-source.
endif.
endloop.
endloop.
Hope this will help you.
Hi Roopa,
you cannot use "AND" in read statement, and in your scenario you want to check the fields like start time and end time with current day system time stamp. I am just giving a rough code in terms of Work Area .
loop at itab into wa. ----> which is Source Package.
loop at itab1 into wa1 where starttime = sy-uzeit and endtime = sy-uzeit.
if sy-subrc = 0.
delete itab where sourcesys EQ wa1-source.
endif.
endloop.
endloop.
Hope this will help you.
Hello Roopa,
Below code should be fine for your requirement:
-----------------------------------------------------------------
DATA: time TYPE timestamp. " = Current Timestamp to get value of current time
* Assign current timestamp to field
GET TIME STAMP FIELD time.
SELECT * FROM zlookup INTO TABLE it_zlookup. " select from table
LOOP AT it_zlookup INTO wa_zlookup WHERE starttime LE time AND endtime GE time.
*now loop on source package
LOOP AT it_sourcepackage INTO wa_sourcepackage WHERE system CS wa_zlookup-srcsystem.
DELETE it_sourcepackage INDEX sy-tabix.
ENDLOOP.
ENDLOOP.
----------------------------------------------------------------
Please let me know if there are any questions.
Thanks
Amit
Hi Amit,
Instead of the source package loop i.e. the below code
LOOP AT it_sourcepackage INTO wa_sourcepackage WHERE system CS wa_zlookup-srcsystem.
DELETE it_sourcepackage INDEX sy-tabix.
ENDLOOP.
Why not use the simpler (and faster)
DELETE it_sourcepackage WHERE system CS wa_zlookup-srcsystem.
The code isn't comparing the fields in two itabs. The code is comparing a field it_sourcepackage with a field in a work area (i.e. wa_lookup-srcsystem).
You're right that there isn't a standard timestamp field, but you can create a timestamp using the CONVERT date d1 time t1 INTO TIME STAMP command.
Hi Roopa,
Do not write select statement inside the loop it will degrade the performance, since for every loop a select statement will be executed. so better to write select statement outside the loop and did you implemented the logic you have mentioned , if not implement it and if you got stuck at any point let us know.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.