Interested by performance issue ?  Read this !  If you can explain, you're a master Jedi !

This is the question we will try to answer...
What si the bottle neck (hardware) of Adobe Premiere Pro CS6
I used PPBM5 as a benchmark testing template.
All the data and log as been collected using performance counter
First of all, describe my computer...
Operating System
Microsoft Windows 8 Pro 64-bit
CPU
Intel Xeon E5 2687W @ 3.10GHz
Sandy Bridge-EP/EX 32nm Technology
RAM
Corsair Dominator Platinum 64.0 GB DDR3
Motherboard
EVGA Corporation Classified SR-X
Graphics
PNY Nvidia Quadro 6000
EVGA Nvidia GTX 680   // Yes, I created bench stats for both card
Hard Drives
16.0GB Romex RAMDISK (RAID)
556GB LSI MegaRAID 9260-8i SATA3 6GB/s 5 disks with Fastpath Chip Installed (RAID 0)
I have other RAID installed, but not relevant for the present post...
PSU
Cosair 1000 Watts
After many days of tests, I wanna share my results with community and comment them.
CPU Introduction
I tested my cpu and pushed it at maximum speed to understand where is the limit, can I reach this limit and I've logged precisely all result in graph (See pictures 1).
Intro : I tested my E5-XEON 2687W (8 Cores Hyperthread - 16 threads) to know if programs can use the maximum of it.  I used Prime 95 to get the result.  // I know this seem to be ordinary, but you will understand soon...
The result : Yes, I can get 100% of my CPU with 1 program using 20 threads in parallel.  The CPU gives everything it can !
Comment : I put 3 IO (cpu, disk, ram) on the graph of my computer during the test...
(picture 1)
Disk Introduction
I tested my disk and pushed it at maximum speed to understand where is the limit and I've logged precisely all result in graph (See pictures 2).
Intro : I tested my RAID 0 556GB (LSI MegaRAID 9260-8i SATA3 6GB/s 5 disks with Fastpath Chip Installed) to know if I can reach the maximum % disk usage (0% idle Time)
The result : As you can see in picture 2, yes, I can get the max of my drive at ~ 1.2 Gb/sec read/write steady !
Comment : I put 3 IO (cpu, disk, ram) on the graph of my computer during the test to see the impact of transfering many Go of data during ~10 sec...
(picture 2)
Now, I know my limits !  It's time to enter deeper in the subject !
PPBM5 (H.264) Result
I rendered the sequence (H.264) using Adobe Media Encoder.
The result :
My CPU is not used at 100%, the turn around 50%
My Disk is totally idle !
All the process usage are idle except process of (Adobe Media Encoder)
The transfert rate seem to be a wave (up and down).  Probably caused by (Encrypt time....  write.... Encrypt time.... write...)  // It's ok, ~5Mb/sec during transfert rate !
CPU Power management give 100% of clock to CPU during the encoding process (it's ok, the clock is stable during process).
RAM, more than enough !  39 Go RAM free after the test !  // Excellent
~65 thread opened by Adobe Media Encoder (Good, thread is the sign that program try to using many cores !)
GPU Load on card seem to be a wave also ! (up and down)  ~40% usage of GPU during the process of encoding.
GPU Ram get 1.2Go of RAM (But with GTX 680, no problem and Quadro 6000 with 6 GB RAM, no problem !)
Comment/Question : CPU is free (50%), disks are free (99%), GPU is free (60%), RAM is free (62%), my computer is not pushed at limit during the encoding process.  Why ????  Is there some time delay in the encoding process ?
Other : Quadro 6000 & GTX 680 gives the same result !
(picture 3)
PPBM5 (Disk Test) Result (RAID LSI)
I rendered the sequence (Disk Test) using Adobe Media Encoder on my RAID 0 LSI disk.
The result :
My CPU is not used at 100%
My Disk wave and wave again, but far far from the limit !
All the process usage are idle except process of (Adobe Media Encoder)
The transfert rate wave and wave again (up and down).  Probably caused by (Buffering time....  write.... Buffering time.... write...)  // It's ok, ~375Mb/sec peak during transfert rate !  Easy !
CPU Power management give 100% of clock to CPU during the encoding process (it's ok, the clock is stable during process).
RAM, more than enough !  40.5 Go RAM free after the test !  // Excellent
~48 thread opened by Adobe Media Encoder (Good, thread is the sign that program try to using many cores !)
GPU Load on card = 0 (This kind of encoding is GPU irrelevant)
GPU Ram get 400Mb of RAM (No usage for encoding)
Comment/Question : CPU is free (65%), disks are free (60%), GPU is free (100%), RAM is free (63%), my computer is not pushed at limit during the encoding process.  Why ????  Is there some time delay in the encoding process ?
(picture 4)
PPBM5 (Disk Test) Result (Direct in RAMDrive)
I rendered the same sequence (Disk Test) using Adobe Media Encoder directly in my RamDrive
Comment/Question : Look at the transfert rate under (picture 5).  It's exactly the same speed than with my RAID 0 LSI controller.  Impossible !  Look in the same picture the transfert rate I can reach with the ramdrive (> 3.0 Gb/sec steady) and I don't go under 30% of disk usage.  CPU is idle (70%), Disk is idle (100%), GPU is idle (100%) and RAM is free (63%).  // This kind of results let me REALLY confused.  It's smell bug and big problem with hardware and IO usage in CS6 !
(picture 5)
PPBM5 (MPEG-DVD) Result
I rendered the sequence (MPEG-DVD) using Adobe Media Encoder.
The result :
My CPU is not used at 100%
My Disk is totally idle !
All the process usage are idle except process of (Adobe Media Encoder)
The transfert rate wave and wave again (up and down).  Probably caused by (Encoding time....  write.... Encoding time.... write...)  // It's ok, ~2Mb/sec during transfert rate !  Real Joke !
CPU Power management give 100% of clock to CPU during the encoding process (it's ok, the clock is stable during process).
RAM, more than enough !  40 Go RAM free after the test !  // Excellent
~80 thread opened by Adobe Media Encoder (Lot of thread, but it's ok in multi-thread apps!)
GPU Load on card = 100 (This use the maximum of my GPU)
GPU Ram get 1Gb of RAM
Comment/Question : CPU is free (70%), disks are free (98%), GPU is loaded (MAX), RAM is free (63%), my computer is pushed at limit during the encoding process for GPU only.  Now, for this kind of encoding, the speed limit is affected by the slower IO (Video Card GPU)
Other : Quadro 6000 is slower than GTX 680 for this kind of encoding (~20 s slower than GTX).
(picture 6)
Encoding single clip FULL HD AVCHD to H.264 Result (Premiere Pro CS6)
You can look the result in the picture.
Comment/Question : CPU is free (55%), disks are free (99%), GPU is free (90%), RAM is free (65%), my computer is not pushed at limit during the encoding process.  Why ????   Adobe Premiere seem to have some bug with thread management.  My hardware is idle !  I understand AVCHD can be very difficult to decode, but where is the waste ?  My computer want, but the software not !
(picture 7)
Render composition using 3D Raytracer in After Effects CS6
You can look the result in the picture.
Comment : GPU seems to be the bottle neck when using After Effects.  CPU is free (99%), Disks are free (98%), Memory is free (60%) and it depend of the setting and type of project.
Other : Quadro 6000 & GTX 680 gives the same result in time for rendering the composition.
(picture 8)
Conclusion
There is nothing you can do (I thing) with CS6 to get better performance actually.  GTX 680 is the best (Consumer grade card) and the Quadro 6000 is the best (Profressional card).  Both of card give really similar result (I will probably return my GTX 680 since I not really get any better performance).  I not used Tesla card with my Quadro, but actually, both, Premiere Pro & After Effects doesn't use multi GPU.  I tried to used both card together (GTX & Quadro), but After Effects gives priority to the slower card (In this case, the GTX 680)
Premiere Pro, I'm speechless !  Premiere Pro is not able to get max performance of my computer.  Not just 10% or 20%, but average 60%.  I'm a programmor, multi-threadling apps are difficult to manage and I can understand Adobe's programmor.  But actually, if anybody have comment about this post, tricks or any kind of solution, you can comment this post.  It's seem to be a bug...
Thank you.

Patrick,
I can't explain everything, but let me give you some background as I understand it.
The first issue is that CS6 has a far less efficient internal buffering or caching system than CS5/5.5. That is why the MPEG encoding in CS6 is roughly 2-3 times slower than the same test with CS5. There is some 'under-the-hood' processing going on that causes this significant performance loss.
The second issue is that AME does not handle regular memory and inter-process memory very well. I have described this here: Latest News
As to your test results, there are some other noteworthy things to mention. 3D Ray tracing in AE is not very good in using all CUDA cores. In fact it is lousy, it only uses very few cores and the threading is pretty bad and does not use the video card's capabilities effectively. Whether that is a driver issue with nVidia or an Adobe issue, I don't know, but whichever way you turn it, the end result is disappointing.
The overhead AME carries in our tests is something we are looking into and the next test will only use direct export and no longer the AME queue, to avoid some of the problems you saw. That entails other problems for us, since we lose the capability to check encoding logs, but a solution is in the works.
You see very low GPU usage during the H.264 test, since there are only very few accelerated parts in the timeline, in contrast to the MPEG2-DVD test, where there is rescaling going on and that is CUDA accelerated. The disk I/O test suffers from the problems mentioned above and is the reason that my own Disk I/O results are only 33 seconds with the current test, but when I extend the duration of that timeline to 3 hours, the direct export method gives me 22 seconds, although the amount of data to be written, 37,092 MB has increased threefold. An effective write speed of 1,686 MB/s.
There are a number of performance issues with CS6 that Adobe is aware of, but whether they can be solved and in what time, I haven't the faintest idea.
Just my $ 0.02

Similar Messages

  • Performance issue in this code

    public int[][] init(int[][] a, int m, int n){
      for(int j=0; j<n; j++){
        for(int i=0; i<m; i++){
          a[i][j] = i+j;
      return a;
    }Just a technical quest faced in one of the interview...
    There is a performance issue in this code. Can you identify, correct and justify your answer?
    Edited by: EJP on 17/10/2011 20:29

    mithu wrote:
    public int[][] init(int[][] a, int m, int n){
    for(int j=0; j<n; j++){
    for(int i=0; i<m; i++){
    a[i][j] = i+j;
    return a;
    }Just a technical quest faced in one of the interview...
    There is a performance issue in this code. Can you identify, correct and justify your answer?Not a good question at all. There's no performance issue here that can be positively identified by inspection. The only potentially significant one is, as EJP pointed out, loss of locality of reference because of the order of the loops. But even that's not a guarantee, since I don't think array layouts are defined by the spec. We could only determine for sure that that's a performance problem by profiling.

  • Performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA)

    Hi Friends
    I am having performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA) and one my client got over 8 thousend employees . This function-module taking forever to read the data. is there any other function-module to read the absences data IT2001 .
    I did use like this .if i take out this F.M 'HR_TIM_REPORT_ABSENCE_DATA_INI' its not working other Function-module.please Suggest me .
    call function 'HR_TIM_REPORT_ABSENCE_DATA_INI'
    exporting "Publishing to global memory
    option_string = option_s "string of sel org fields
    trig_string = trig_s "string of req data
    alemp_flag = sw_alemp "all employee req
    infot_flag = space "split per IT neccessary
    sel_modus = sw_apa
    importing
    org_num = fdpos_lines "number of sel org fields
    tables
    fieldtab = fdtab "all org fields
    field_sel = fieldnametab_m. "sel org fields
    To Read all infotypes from Absences type.
    RP_READ_ALL_TIME_ITY PN-BEGDA PN-ENDDA.
    central function unit to provide internal tables: abse orgs empl
    call function 'HR_TIM_REPORT_ABSENCE_DATA'
    exporting
    pernr = pernr-pernr
    begda = pn-begda
    endda = pn-endda
    IMPORTING
    SUBRC = SUBRC_RTA
    tables
    absences = absences_01
    org_fields = orgs
    emp_fields = empl
    REFTAB =
    APLTAB =
    awart_sel_p = awart_s[]
    awart_sel_a = awart_s[]
    abstp_sel = abstp_s[]
    i0000 = p0000
    i0001 = p0001
    i0002 = p0002
    i0007 = p0007
    i2001 = p2001
    i2002 = p2002
    i2003 = p2003.
    Thanks & Regards
    Reddy

    guessing will not help you much, check with SE30 to get a better insight
    SE30
    The ABAP Runtime Trace (SE30) -  Quick and Easy
    what is the total time, what are the Top 10 in the hitlist.
    Siegfried

  • TS4009 my ipad wont log in it says this ipad  cannot be backed up because there is no enough icloud storage available. you can manage you storage in setting. but i cannot go to settings

    my ipad wont log in it says this ipad  cannot be backed up because there is no enough icloud storage available. you can manage you storage in setting. but i cannot go to settings.. and i can not turn it off and i can not log in

    If your iPad is frozen and unresponsive, reset it by holding the power and home buttons at the same time until you see the Apple logo, then release.

  • Can you trade in your iPad for another one???.......... If you can would you get your money back?????

    Can you trade in your iPad for another one???.......... If you can would you get your money back?????

    Generally, no.  You have 2 weeks from purchase.   But you have options. Www.gazelle.com will make you an offer. Sell it to them, then go buy what you want.  What is the issue?  Just trading for a different machine will get you only what you had in the first place.

  • Hello, is there a way to redact a word or item from a pdf using adobe pro X the same way you can if you convert a word doc using pro X on a pc?

    hello, is there a way to redact a word or item from a pdf using adobe pro X the same way you can if you convert a word doc using pro X on a pc?

    If the document is not a scanned image or protected from editing then you should be able to edit it. I would have to guess you have a scan and when you converted to Word, you ran OCR (Optical Character Recognition) on it converting the scanned image to live text.
    This is the forum for the free Adobe Reader which can not edit or redact.

  • Performance issue on this.a = a

    Hello to all the java gurus. I was wondering on whether there is a performance issue on the coding below :
    [1] public void setName( String name ) { this.name = name; }
    vs.
    [2] public void setName( String _name ) { name = _name; }
    If i use [1], will it requires extra computation of finding current object followed by finding its name data member compare to [2] which directly distinguished by using different variable name?
    many thanks for those who try to solve this puzzle of mine.

    I agree with dubwai.. my variable names are pretty
    long, but descriptive. I also use (as a holdover from
    my corporate project days) a naming convention that
    specifies which variables are local, passed as params,
    or global, which eliminates the need for this. in most
    cases. If you need to use this. because you
    have two variable names that are identical, I would be
    questioning if one couldn't be named something else.I think it there are just some errors that can't be avoided by anything less than careful programming. I think a lot of times people obsess over things like variable naming schemes while writing 200 line methods with multiple nested and unnested loops. The easiest way to make code readable is to break out everything in 5 to 20 line methods (give or take some lines depending on how you count.) Of course, sometimes this isn't feasible or useful but it's still a good rule of thumb. If you can acheive this, the variable naming scheme isn't really a significant factor in readability. You could name everything like y4gr5x6 and you'd still be able to figure it out.

  • Performance issue in this query:

    Hi,
    Here is the query:
    SELECT COLLECTIONKEY, FLOWSYSKEY, LIFECYCLENUMBER, PUBLICVERSION, PUBLICOPERATION,
    STATUSCODE, VALUEDATE, REASONCODE FROM AA out WHERE COLLECTIONKEY
    LIKE '1437023L%' AND COLLECTIONVERSION = ( SELECT MAX(COLLECTIONVERSION) FROM cfdg_owner.AA inn WHERE inn.FLOWSYSKEY=out.FLOWSYSKEY)
    Now this table AA has non clustered index on CollectionKey and CollectionVersion.
    The above query will return only 4 records, but still the optimizer is using index .
    Fyi, AA table is huge table with records in millions.
    SELECT STATEMENT     8.0     8     58591     1     108     8                         ALL_ROWS                                                       
    FILTER                              1                                                                                
    TABLE ACCESS (BY INDEX ROWID)     5.0     5     36827     2     216     1     CFDG_OWNER     TB_PUBLIC_CF     BY INDEX ROWID     TABLE     ANALYZED     1                                                  
    INDEX (RANGE SCAN)     3.0     3     21764     2          1     CFDG_OWNER     IDX2_TB_PUBLIC_CF     RANGE SCAN     INDEX     ANALYZED                    1                                   
    SORT (AGGREGATE)                    1     41     2               AGGREGATE                                                                 
    INDEX (RANGE SCAN)     3.0     3     21764     1     41     1     CFDG_OWNER     IDX1_TB_PUBLIC_CF     RANGE SCAN     INDEX     ANALYZED                    1
    Plus the response time of this query is very fast. When i am forcing optimizer not to use Index, its taking more time.
    How come Index range scan is performing better in this case as compared to FULL Scan?
    Version is:
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE     10.2.0.4.0     Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Any more information required, please let me know.
    Thanks.
                                                      1

    It only returns 4 records, but how many does it have to scan through and eliminate to satisfy the MAX condition? ie) how many versions are there per key?
    It's quite possible this would be a more efficient query for you (it will obviate the secondary index range scan the current query is utilizing).
    SELECT
      COLLECTIONKEY,
      FLOWSYSKEY,
      LIFECYCLENUMBER,
      PUBLICVERSION,
      PUBLICOPERATION,
      STATUSCODE,
      VALUEDATE,
      REASONCODE
    FROM
      SELECT
        COLLECTIONKEY,
        FLOWSYSKEY,
        LIFECYCLENUMBER,
        PUBLICVERSION,
        PUBLICOPERATION,
        STATUSCODE,
        VALUEDATE,
        REASONCODE,
        COLLECTIONVERSION,
        MAX(COLLECTIONVERSION) OVER (PARTITION BY FLOWSYSKEY) AS MAX_COLLECTIONVERSION
      FROM AA
      WHERE COLLECTIONKEY LIKE '1437023L%'
    WHERE COLLECTIONVERSION = MAX_COLLECTIONVERSION;But without knowing a lot more about your data distributions, etc... it's just a guess.

  • Performance issue with this query.

    Hi Experts,
    This query is fetching 500 records.
    SELECT
    RECIPIENT_ID ,FAX_STATUS
    FROM
    FAX_STAGE WHERE LOWER(FAX_STATUS) like 'moved to%'
    Execution Plan
    | Id  | Operation                   | Name                | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT            |                     |   159K|    10M|  2170   (1)|
    |   1 |  TABLE ACCESS BY INDEX ROWID| FAX_STAGE           |   159K|    10M|  2170   (1)|
    |   2 |   INDEX RANGE SCAN          | INDX_FAX_STATUS_RAM | 28786 |       |   123   (0)|
    Note
       - 'PLAN_TABLE' is old version
    Statistics
              1  recursive calls
              0  db block gets
             21  consistent gets
              0  physical reads
              0  redo size
            937  bytes sent via SQL*Net to client
            375  bytes received via SQL*Net from client
              3  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
             19  rows processed
    Total number of records in the table.
    SELECT COUNT(*) FROM FAX_STAGE--3679418
    Distinct reccords are low for this column.
    SELECT DISTINCT FAX_STATUS FROM FAX_STAGE;
    Completed
    BROKEN
    Broken - New
    moved to - America
    MOVED to - Australia
    Moved to Canada and australia
    Functional based indexe on FAX_STAGE(LOWER(FAX_STATUS))
    stats are upto date.
    Still the cost is high
    How to improve the performance of this query.
    Please help me.
    Thanks in advance.

    With no heavy activity on your fax_stage table a bitmap index might do better - see  CREATE INDEX
    I would try FTS (Full Table Scan) first as 6 vs. 3679418 is low cardinality for sure so using an index is not very helpful in this case (maybe too much Exadata oriented)
    There's a lot of web pages where you can read: full table scans are not always evil and indexes are not always good or vice versa Ask Tom &amp;quot;How to avoid the full table scan&amp;quot;
    Regards
    Etbin

  • 10.4.9 issues - read this doc if it applies it may help.

    http://docs.info.apple.com/article.html?artnum=106214
    I'm hoping this helps some of you.
    Here is a summary, first paragraph actually:
    With Mac OS X 10.4.3 or later, Disk Utility can verify your computer's startup disk (volume) without requiring you to start up from another volume. This feature is called "Live Verification." If Disk Utility discovers any issues that require a repair, you will need to start up from your Mac OS X Tiger DVD or CD and use Disk Utility on that disc to make repairs. (You can't repair your startup volume while your computer is started up from it.)

    you may want to try this link as well
    http://docs.info.apple.com/article.html?artnum=106214

  • At a loss with my Galaxy battery Problems.  If you can help you are awesome

    So about 2 months ago my Galaxy 1's battery got really low but when I plugged it into charge it it said "Use genuine battery only.  Shutting down in 10, 9, 8, ...ect..."
    After calmly trying to explain to the phone that the battery it had was the one it had always had, I decided "well it's 1.5 yrs old so it's possible the battery has gone bad."  Got a new battery and it has worked just swell up until now.  Same scenario.  Battery was really low, plugged in the charger (which is the original wall-wart that it came with, has always worked..ect..) and we're back to the use genuine battery only stuff again. 
    I am an electronics tech but admit I have very little knowledge of these particular kind of Li-ion batteries.  There are 4 terminals but I know, because of its 3.7V nomimal, that it is only a one cell battery so I was wondering is it still possible the battery can get out of balance somehow when it gets too discharged and cause this issue?  Is there something I can do as far as manually balancing these terminal? Is this balance idea completely wrong anyway? Is there anybody who knows what causes this/how to fix it?  I guess what I ultimately want to know is: What is the phone seeing on this battery that is making it think it's not genuine???? 
    I am very frustrated because, as I said earlier, I am just a poor electronics tech and really don't want to pony up another 40 or 50 bucks when this could just happen again and I will be getting a new in August anyway.
    HELP!!!!
    please

    Thats not the issue I can assure you I know about vsync I have allways used it I just hate screen tearing. The problem isnt going to 30fps Ive tried real time fps monitoring. It happens with literally every game no matter what the graphics settings Is.
    I have however narrowed down the issue, I have connected an external screen via hdmi which bypasses the intel graphics adaptor and its butter smooth, The problem lies somewhere with how optimus works or the driver. As optimus always uses the intel graphics adaptor to output to the laptop display that has to be the issue. I have tried updating the intel display adaptor drivers but no joy

  • I can't belive it. You have to help me.. you can. but you don't want to. i did what you said to me. I call the police. but i need to localizate with you help. PLEASE. I'M BEGGING YOU.

    This ipod means a lot to me. Not because it's an apple ipod, because my mom bought me with all her money.
    I know this is not your problem, but i NEED to find it. Only you can't help me.
    I know i'm not a important customer but at least try to do something .
    I don't know who is answering this message, i hope if someone read this message, can help.
    You CAN do it.. but you don't want to.
    I'm just telling you, to try to find it. Because the APP doesn't work to ipod's.
    at least, you should to get better your apps.
    PLEASE, HELP ME

    Sorry but the only help you have is the local police.
    Change your iTunes (Apple ID) password along with any other password that was stored in the iPod.  If any passwords are associated with credit cards, contact the CC company and get your card replaced (with a new number).  If any passwords are associated with your bank or any savings institution, contact them also and discuss approprate action with them.
    The "Find my..." function is pretty much useless if the device is in the hands of a thief.  All that is necessary is for the thief to connect to any computer with iTunes and "Restore as new."
    The only real protection you have is with the personal information on the device rather than the physical device itself.  This requires action before the device is lost/stolen.  Something as small as an iPod should have a strong 8-digit (or longer) password AND be configured for automatic wipe in the event of ten consecutive incorrect password entries.

  • Does Apple support a program where you can trade you iPod for cash or for the newer iPod?

    I really want the new ipod once it come out, just wndering!!

    Only Apple program is one where you can trade your iPod for 10% off a new one.
    If your iPod is relatively new and good condition, you would probably get more than this by selling it.
    However if your iPod is completely smashed up, they will still give you the 10% off.

  • Performance issue with this complex query

    Please ignore this thread(post)
    This query fetches a lot of data and takes more than 4 t0 5 hrs to retrieve them.
    I have tried to get the explain plan the display cursor and the TKPROF for the same but then the query utilizes more than 100GB temp space and it fails to generate any.
    What I have is the spool file which is pasted below along with the query.
    Database version: 11g
    I'm looking forward for suggestions how to improve the performance of this statement
    Please ignore this thread(post)
    Edited by: user13319084 on May 30, 2011 12:34 AM

    You provide no information that can be used in answering your question on how to improve the query.
    In absence of technical information, all that we can discuss is conceptual issues. Like why is the query that complex? A common answer is that the underlying data model lacks the intelligence and this now requires the intelligence to be build into the query.
    You need to look at the data model and the query in order to address this performance problem - and make sure that the actual business requirements is clearly identified and understood.

  • Performance Issue with this code

    Hi Gurus,
    Can anyone please help tweak the performance of this program.
    REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SPREPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]2 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]3 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]4 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]5 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]6 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]7 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]8 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       K

    The first SELECT looks a bit shaky. Have you done a performance trace (ST05) to find out where the problem is?
    Rob

Maybe you are looking for

  • Addition of result column in SRM 7.0 POWL Report "Contracts for Supplier"

    Hi, We are on SAP SRM 7.0 SP08. There are two POWL reports associated with contracts i.e. "Contract for Supplier" and "Contract for Product". We want to add two fields/columns to the report (Payment Type and Responsible Employee). As per SAP standard

  • Stopping sounds in an embedded MC

    is there a way to stop the sounds of a movieClip (with embbeded video) and still keep the clip playing?... I know i've seen this on the videoGallery example, but i can't make their method work... ><

  • (HOW TO FORM INTERNAL TABLES) INHR

    HAI ALL.      S.NO     TABLE NAME   fIELDNAME                       1.     T71JPR09      PROVIDER                     2.     T71JPR09      JOBCODE       3.     PA0000     PERNR       4.     HRP1000     STEXT       5.     T71JPR09      JOBCODE       6

  • Windows activation after recovery

    Hello Jeff,   Sir bundle of thanks that u always reply to my post on forum but no response from your team after I reply to your mail.... that is after sending my details to u... plz sir tell me some online solution as I can't visit HP center because

  • SD Quotation Creation BAPI

    Hi Everyone, I'm creating Quotation thru a "Z" program by calling the BAPI "BAPI_QUOTATION_CREATEBOS". All paramteras are passed thru the flat file table and successfully got created. When I look into the Costing Model values, they are still empty. K