Logic Abap

Please correct the logic on this
TABLES : RSREQICODS.
DATA: SUBRC LIKE SY-SUBRC,
      RETURNCODE(1) TYPE C,
      count.
Types: BEGIN OF WT_RSREQICODS,
        TABNAME LIKE RSREQICODS-TABNAME,
        RNR LIKE RSREQICODS-RNR,
      END OF WT_RSREQICODS.
DATA: IT_RSREQICODS TYPE TABLE OF WT_RSREQICODS,
      WA type table of WT_RSREQICODS.
SELECTION-SCREEN: BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_TAB FOR RSREQICODS-TABNAME.
PARAMETERS: P_NBDAY(3) TYPE N DEFAULT 8.
SELECTION-SCREEN: END OF BLOCK B01,
                  SKIP,
                  BEGIN OF BLOCK B02 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_TEST RADIOBUTTON GROUP G1,
P_REEL RADIOBUTTON GROUP G1.
SELECTION-SCREEN: END OF BLOCK B02.
START-OF-SELECTION.
CLEAR IT_RSREQICODS.
REFRESH IT_RSREQICODS.
SELECT TABNAME INTO  TABLE IT_RSREQICODS FROM RSREQICODS
                       WHERE TYP = 'O'
                         AND TABNAME IN S_TAB
                    ORDER BY TABNAME.
LOOP AT IT_RSREQICODS into Wa .
   If count(WA-RNR) > 2.
   DELETE RSREQICODS from table WA  .
  ENDIF.
endloop.

HI Tamkris
FIrst change ur line of code to the following
DATA: IT_RSREQICODS TYPE <b>STANDARD</b> TABLE OF WT_RSREQICODS,
WA type WT_RSREQICODS.
<b>then ur select statement doesnot conform on the number of field declared in IT_RSREQICODS because it contains two fields</b>
<b>TABNAME LIKE RSREQICODS-TABNAME,
RNR LIKE RSREQICODS-RNR,</b>
<b>You only fetch TABNAME from RSREQICODS, TIP used indention to make ur code readable</b>
SELECT TABNAME
       <b>RNR      'ADD THIS Field</b>
      INTO TABLE IT_RSREQICODS
   FROM RSREQICODS
      WHERE TYP = 'O'
      AND TABNAME IN S_TAB
ORDER BY TABNAME.
<b>ADD the code to check if the select statement is successful</b>
IF SY-SUBRC = 0.
' place code here
ENDIF.
<b>'ADD DELETE DUPLICATE RECORDS HERE BEFORE PROCESSING THE LOOP</b>
LOOP AT IT_RSREQICODS into Wa .
If count(WA-RNR) > 2.
DELETE RSREQICODS from table WA .
ENDIF.
endloop.
<b>ADD REFRESH, CLEAR AND FREE to tabels for optimizationand Performance</b>
REFRESH IT_RSREQICODS.
CLEAR Wa.
FREE: IT_RSREQICODS,
      Wa.
Hope it helps You
Regards,
Chris
Message was edited by: christopher bautista

Similar Messages

  • Text Variable With Customer Exit Logic/ABAP Code

    Hi Experts,
    Could you please help me with the Logic/Code that i need to use in Calculacting The TEXT Variable Using CUSTOMER EXIT
    I had a rolling report in which there are 14 Calculacted Keyfigures  (Not Restricted KF),Which are
    M-1,M-2,M-3,M-4,M-5........M-14
    In MAY2009
    M-1 represents (Current Month -1)  APR2009
    M-2 represents (Current Month -2)  MAR2009
    M-3 represents (Current Month -3)  FEB2009
    M-4 represents (Current Month -4)  JAN2009
    M-5 represents (Current Month -5)  DEC2008
    M-6 represents (Current Month -6)  NOV2008
    M-7 represents (Current Month -7)  OCT2008
    M-13 represents (Current Month -13)  APR2008
    M-14 represents (Current Month -14)  MAR2008
    In JUNE2009
    M-1 represents (Current Month -1)  MAY2009
    M-2 represents (Current Month -2)  APR2009
    M-3 represents (Current Month -3)  MAR2009
    M-4 represents (Current Month -4)  FEB2009
    M-5 represents (Current Month -5)  JAN2009
    M-6 represents (Current Month -6)  DEC2008
    M-7 represents (Current Month -7)  NOV2008
    M-13 represents (Current Month -13)  MAY2008
    M-14 represents (Current Month -14)  APR2008
    Currently the Description of CKF is named as M-1,M-2..M-14.My requirment is to develop Text Variables that displays the description as MMMYYYY

    Sample code, NO syntax check...!!
    CASE i_vnam.  " Variablenname
      WHEN 'M-1'. "For Variable <M-1>
       Data: l_peri type E_BUPER, "Declare variable for Period
                l_year type E_GJAHR "Declare variable for year
        IF i_step = 2.
          DATA l_s_range LIKE LINE OF e_t_range.
          CLEAR l_s_range.
          CALL FUNCTION 'DATE_TO_PERIOD_CONVERT' " By providing Date this FM gives period and year
           EXPORTING
             I_DATE           = SY-DATUM "System Date
             I_PERIV         = V3 "Fiscal Variant
          IMPORTING
             E_BUPER       = l_peri "for period is date is today period = 005
             E_GJAHR       = l_year. "for Year = 2009
          l_peri = l_peri - 1. "To reduce 1 from period (005 - 1 = 004)
          IF l_peri = '004'       "Check value of period.
          Concatenate 'APR' l_year into l_s_range-low. "concatenate 'APR' & Year into Low.
          l_s_range-sign   = 'I'.
          l_s_range-opt    = 'EQ'.
                APPEND l_s_range TO e_t_range.
        ENDIF.
    For M-2 subtract 2 and repeate same.

  • Pl. provide ABAP logic

    Can any body help me in providing the logic (ABAP logic-infopackage) for extracting data for 6th month considering sydatum.
    Logic should be on Caday.
    Example: If I am executing I/P today i.e. 13.01.2012, I should get the data of 01.06.2011 to 30.06.2011.
    Please help. 
    Thanks in Advance.
    Maddali VSKP

    Hi,
    As I am not core ABAPER, I tried below logic in the development. Logic is working fine. I am getting expected results.
    DATA: l_cur_month(2) type n,
    l_pre_month(2) type n,
    l_cur_year(4) type n,
    z_ppredat type DATS,
    z_ppredat1 type INT1,
    z_ppredat2(8) type n,
    z_ppredat3(2) type n,
    l_pre_year(4) type n.
    data: l_idx like sy-tabix.
      read table l_t_range with key
           fieldname = 'CALDAY'.
      l_idx = sy-tabix.
      l_cur_month = sy-datum+4(2).
      l_cur_year = sy-datum(4).
      l_pre_year = sy-datum(4).
      if l_cur_month >= 7.
        l_pre_month = l_cur_month - 7.
      endif.
      if l_cur_month <= 6.
        l_pre_year = l_cur_year - 1.
        l_pre_month = 12 - ( 7 - l_cur_month ).
      endif.
      break-point.
      concatenate l_pre_year  l_pre_month  '01'
      into z_ppredat.
      CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
        EXPORTING
          IV_DATE       = z_ppredat
        IMPORTING
          EV_DAYS       = z_ppredat1 .
          z_ppredat3 = z_ppredat1.
      concatenate l_pre_year  l_pre_month z_ppredat3
      into z_ppredat2.
    concatenate  "l_pre_year  l_pre_month  z_ppredat1" into z_ppredat2
      l_t_range-sign = 'I'.
      l_t_range-option = 'BT'.
      l_t_range-low = z_ppredat.
      l_t_range-high = z_ppredat2.
      modify l_t_range index l_idx.
      p_subrc = 0.
    Request you to help me to validate the logic.
    Thanks in Advance,
    Maddali VSKP

  • Creation of Generic Data source using function module based on the program which was used to created ABAP report

    Hi,
    We have a requirement to create a BI report based on plant maintenance report. The plant maintenance report is based on a ABAP program with complex logic. My question is i want create a Generic Datasource using Function module and can I include the logic(Abap Program) that is used for plant maintenance report in the function module? Please share your thoughts.
    Thanks,
    Ravi

    Hi,
    Step1-Create a table structure which you need to create same as the fields you require in you data source.
    Step 2-create a custom abap program and inside that call the Client abap program with the selections as required and save the result data in some table
    Step 3-create infoset query.In the infoset query give your table structure name and  program name which you developed.
    Step4-create data source on top of that query

  • If statment in sap script

    hi,
    IF ( &STAX3& = '4.00' OR &STAX3& = '12.50' )
    XXXXXX,,  ,,&text3& &STAX1&%   ,,,,  &TOT_STAX1(C.0)&
    XXXXXX,,  ,,&text3& &STAX2&%   ,,,,  &TOT_STAX2(C.0)&
    ,,,,&text51&,,,,&tot_tcost&
    ,,,,,,,,&TOT_FINAL(C.0)&
    ELSE
    XXXXXX,,  ,,&text3& &STAX&%   ,,,,  &TOT_STAX(C.0)&
    ,,,,&text51&,,,,&tot_tcost&
    ,,,,,,,,&TOT_FINAL(C.0)&
    ENDIF
    i am using this code.
    i have one doubt in if statment we can use this syntax
    IF ( &STAX3& = '4.00' OR &STAX3& = '12.50' )
    this is correct or not.
    if i use this code if statment is not excuting.
    pls clarify my doubt.

    Hi Venkat,
    Usually we'll write all the logical ABAP statements in Subroutine pool, instead of writing them in the script form directly.
    Use PERFORM statement in the script form as shown below & write the code u want in that....
    /:   PERFORM GET_MERCANTIL IN PROGRAM cust_invoice
    /:   USING &RKWA-BUKRS&
    /:   USING &RKWA-LIFNR&
    /:   USING &BKPF-GJAHR&
    /:   CHANGING &V_MERCANTIL&
    /:   ENDPERFORM
    GT   Insc.Reg.Mercantil    &V_MERCANTIL&
    GT is the paragraph format.
    Go to SE38 & create the program,cust_invoice ( called as Subroutine pool ) & write the FORMs in that....
    U can use the normal ABAP coding in that....
    Hope this will work.
    Try this out & let me know if there are any issues.
    Reward points, if useful.
    Pavan.

  • Unable to find SWCV in BW system for inbound proxy

    Hello Friends,
    There is one interface running in our system. It is FILE to PROXY. Every day MDM sends some vendor details in files form. PI polls the file and map to structure for BW. (BW is SAP System).
    In Operation Mapping, Sender Side : Our own interface and structure is used. On the Receiver side, 'GenericVendorIN' interface from SAP SWCV 'BI CONT' is used.
    Messages are processed successfully for this interface in PI (PI 7.1) and failed in BW side due to application error. Not all messages, few messages.
    When we try to troubleshoot the business logic (ABAP) written for this inbound interface in BW system, this SWCV BI CONT is not displayed in SPROXY transaction. But, we see successful messages and failure messages in BW system. (Txn: SXMB_MONI). ESR is connecting fine. Our SWCV is adisplayed correctly.
    Friends, could you please clarify why SAP Standard SWCV BI CONT is not displayed in SPROXY transaction? For any errors, how do we troubleshoot then on the inbound side i.e in BW system.
    Thanking you.
    Kind regards,
    Jegathees P.

    hi,
    In BW, check in tx SXMB_ADM, option Integration Engine configuration, if you have in category RUNTIME, parameter IS_URL something like that "dest://<NameOfYourRfcDestination>".
    and in SM59 (of BW), check that you have the same RFC destination (type H).
    or maybe you use a Java proxy, instead of an abap proxy.
    regards.
    Mickael

  • Ignore time stamp in file name to load infopackage

    Hi
    Everyday a .csv file gets written into a particular folder in my application server. the filename is as TESTYYYYMMDDHHMM.csv.
    Now i have written a program to pick up the file with TESTYYYYMMDD, but the time stamp doesnt match, hence i have to ignore it when i read the file.
    Can someone please tell me some simple logic/Abap code to ignore the time stamp in the name? i have tried using TESTYYYYMMDD*.csv, but that doesnt work.
    Please help. this is very urgent.
    Thanks
    Sushmita

    I read the content of the folder into an internal table usign EPS_GET_DIRECTORY listing. i cud read that into a variable, using a simple loop.
    and pass it to the Infopackage as file name.

  • Material number usage instead of equipment...

    hi all,
    cs will be implemented in a company. serial number is not being used in the company. and they don' t want to create equipment master data for the materials returned by customers. there can be a problem if we just use the material number(for notification and for service order)?

    HI,
    you have a only one optio is..........You should track PO date/SO date/Invoice date as a warraty start date.....
    if you do simple customisation..you can do it this.
    first........you decide which document you want to count warranty period...
    in that make a manditory field "Warranty".
    Later if product comes for service....you can make logice(ABAPer) ..this field should appear in service notification...and counts the days.
    hope you helpful for you..
    With regards
    Luckky

  • How to apply some code to event?

    Hello Experts,
    My BI consultant has cretaed one event. I need to apply my logic(abap code), when this event ger trigger.
    So where can I write my code in event? Please provide some document if anyone have...
    Thanks,
    Regards,
    Sagar

    Hi Sagar,
    There might be some other steps. Generally, what I do in BI is follows.
    1. Create the event.
    2. Have my logic in an ABAP program and assign it a program name.
    3. Using SM36, I will define a new background job. Give your job name and job class accordingly.
    4. Click on start condition and give your event name in the space provided for 'After Event'.
    5. Now click on 'Step'. In the 'ABAP Program' section give your program name. Give variant name if any.
    Finally, you will see this method is more flexible than any.
    Assign points if useful as this is the only way to say thanks.
    Regards,
    Srinivas

  • SQ01 Report Question

    Hi
    Is it possible to create a query using SQ01 where we can apply certain condition on the date (select data based on current date minus 13 periods) for example you enter 02.2014 then we want the report to select all data up to 01.2013.
    Can anyone recommend the ABAP code that I can input on the query to meet the above requirement?
    thanks
    Joe

    Hi,
    Instead of giving logic (ABAP code) in report, you can give also do following :
    1. Make Posting date as input date.
    2. Enter all required parameters.
    3. Save
    4. Do as per below screen shots
    Please click on Green tick
    Please click on Green tick
    Save
    We hope your doubts are cleared else feel free to revert.
    We have protected the filed as no one should change the date.
    Regards,
    Tejas

  • Trigger by time and event

    Hi Gurus,
    Is it possible to have a batch job or process chain to be triggered by BOTH an event AND time at the same time?
    How about for a job or chain to be triggered ONLY when 2 Events have triggered?
    So far, I see that only 1 event is possible per trigger.
    Can a program check if a particular event has been triggered? Is this status set/saved in a table?
    Thanks,
    Pascal Gabin

    Dear Pascal Gabin,
    I hate to write the following logic.. but just thining if incase if youhave not thought of this.
    1) EVENT A, linked to ABAP A
    2) EVENT B, linked to ABAP B
    Logic ABAP A:
       - Updates FLAG A, table COMMON. 
       - Checks the Flag B is X or not..
            if it is Space.
               exit.
            else.
               clear the FLAGS.
             Trger the event C, by BP:EVENT_RAISE FM.      
    Logic ABAP B:
       - Updates FLAG B, table COMMON. 
       - Checks the Flag A is X or not..
            if it is Space.
               exit.
            else.
               clear the FLAGS.
             Trger the event C, by BP_EVENT_RAISE FM.      
    Event C is maaped to your Process chian or JOB..
    Not a good one.. but i think it can satify the functionality of what your loking for..
    table Common will have 2 fields FLAG_A and FLAG_B.
    jst trying to read FLAGS instead of events..
    You can also check for event tables in the work flow form.. not sure you get it.. but should give you many table names there..
    regards,
    Hari

  • User exit for PA61 - Validations to IT2001 & IT2002 upon save

    Hi,
    I got a requriement as follows:
    User enters time thru PA61 and I need perform some calculations upon saving the weeks time in PA61.
    I have to do two tasks:
    1) I need to read the hrs entered by the user in PA61 for that week
    2) Upon save, I need to calculations and save that to IT2001 & IT2002 based on Absence types.
    PLease let me know any user exit, where i can write code & how to read the time for the particular week.
    Thanks,
    Shrini

    HI Shreenivas
    As Omid said , PA61 is T-Code for maintain time data its like PA30. but if you need to put any validation or any business check, you can use the User Exit  (enhancement) PBAS0001 via t-code SMOD.
    here you can select the functional module EXIT_SAPFP50M_002 and write your customer logic (ABAP code) for IT2001 and IT2002 in the include ZXPADU02.
    Thanks,
    Dinesh

  • PO validation for SCE

    Hi Experts,
    Is there a way to ensure that before a production order can be created, the system would check if a standard cost estimate exist for the material to be produced?
    Thanks and best regards,
    Ley

    Hi,
    include ZXCO1U06 is processed when saving a production order. This is the place to add customer logic (Abap'er can do this). I had it once to check (dependent on the valuation class of the finished good and PP-order type) if there is an released plan cost estimate, otherwise the PP-order can not be saved.
    Best regards, Christian

  • BSP Element Expressions XML Parameters

    Hi, can anyone please give me a tip or a small example of a use of parameters in XML BEE? They are defined in a BSP and then set there in the bee SET method of CL_BSP_BEE_XML. Brian McKellar gives an example in his Weblog /people/brian.mckellar/blog/2003/10/30/bsp-programming-bsp-element-expressions-bees but I have a different situation and dont understand what they might mean for me. Thanks for any information. Best regards David Lawn

    Hi Brian, thank you very much.
    In fact I have success with the tutorials you have given. I still have some difficulties but believe they can be overcome:
    1. I am in a method of the bsp application class. I have dumped the code into this method from a bsp page include fragment.
    2. Thus, in this method, I now have business logic abap determining which <htmlb elements are created and what values the variables of these elements have. Thus at runtime I pass to the bee a concatenated string like '<htmlb:textView id  ="' l_id_element_name ' text      = "' l_text 'design    = "' l_design '"' ... '/>'. I had figured I had, at runtime, no variables and so needed no parameters. In fact, I have had to find that if I do not code parameters then adding in a second piece of <htmlb code crashes the bee and I loose the browser display of the first one. If I parameterise the first and the second, then I have both. So thats clear. I have also found that bee string syntax is totally strict. I also looked at bee->m_dom dom_table in the debugger, together with the parameters, which helped me understand.
    I am adding in bits of the huge amount of business logic at a time to keep the bee string consistent.
    3. After setting the bee I pass it back to the view include that called my method (I have a nice ddic structure for that) and display the result as you do in your tutorial.
    4. The total result thus is that I no longer need business logic in my view includes and can create html from htmlb in the application class method, which is what I need. Thanks!
    4. My need: I firstly just need to get a form onto the browser as quickly as possible so that other project members can see it and plan. Performance is secondary at the moment. I am happy to use the xml bee.
    5. The bsp I work with has a strange structure, with a page with flow logic <bsp:goto-ing a controller which calls a view with many includes, one of which is mine (which also has includes). So your other suggestion, using views, will also be followed up as soon as I get my page up and visible.
    Kind regards David

  • Logical command in ABAP.....Urgent

    Hi,
      i am pretty new using ABAP program so i neeed help urgently. i am trying to move a file on the application server from one directory to the other and i was using the open dataset function to do that. but the file i am trying to move is pretty big and because i am using internal table to store, it is causing problems with the space.
      i have consulted the basis guys and they have managed to create a logical file for copying from one directory to the other on the application server. to help you furthter. i am enclosing the mail sent to me.
    I have created a logical command which should copy the file from one location to the other but you need to pass it the source dir and file name and the destination dir and file name.
    The logical command is ZCOPY and uses cmd /c copy
    Copies one or more files to another location.
    COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
         [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
      source       Specifies the file or files to be copied.
      /A           Indicates an ASCII text file.
      /B           Indicates a binary file.
      destination  Specifies the directory and/or filename for the new file(s).
      /V           Verifies that new files are written correctly.
      /N           Uses short filename, if available, when copying a file with a
                   non-8dot3 name.
      /Y           Suppresses prompting to confirm you want to overwrite an
                   existing destination file.
      /-Y          Causes prompting to confirm you want to overwrite an
                   existing destination file.
      /Z           Copies networked files in restartable mode.
    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.  Default is
    to prompt on overwrites unless COPY command is being executed from
    within a batch script.
    the problem now is i have no idea about how to use the logical command. can any one help me.
    Thank you,
    Ravi.

    If memory is not an issue, then there should be no reason why this should not work.
    report zrich_0001.
    parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
                d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
    data: itab type table of string with header line.
    start-of-selection.
    * Read old file
      open dataset d1 for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset d1 into itab.
          if sy-subrc <> 0.
            exit.
          endif.
          append itab.
        enddo.
      endif.
      close dataset d1.
    * Write to new file
      open dataset d2 for output in text mode.
      loop at itab.
        transfer itab to d2.
      endloop.
      close dataset d2.
    * Delete the old file
      delete dataset d1.
    Regards,
    Rich Heilman

Maybe you are looking for

  • Apache + php blank page (again)

    Hey, i got problems with php and apache, its just that when i have PHP enabled, apache aint serving me anything, i checked permissions, triple checked all my configs and i still cant find the mistake, i also searched this board but nothing helped me,

  • Report shows no data in the Viewer

    Hello, i'm new to Crystal Reports and i have to develop a few Reports. I load the data with a stored procedure form a sql-server. This is working and i get all datas i need. But the Report Viewer doesn't show any data. I don't know why. If i do it ov

  • BEx Query Designer,点击新建,选择信息范围时,提示:严重服务器错误

    各位好         我在新建bw query时,点击新建按钮,选择信息范围,然后就没反应了,估计10分钟后,弹出一个消息: 严重服务器错误 服务器会话可能已终止:此连接不再存在或不稳定 再次登录到服务器以创建新连接 getnodes: rfc exception 在st22中也查看了,是一个超时的error: The program "SAPLRZX0" has exceeded the maximum permitted runtime without interruption and h

  • EBS Home Page color is trun on blue instead of the origenal color

    Hi ALL : In My production Instance , after bounce the services , i found that APPS home page has a different color than usual , its turned to blue color My environment installed in HPUX Itanium EBS version : 12.1.1 Any help is much appreciated . Hesh

  • Can't install updates to my laptop

    I have photoshop 12 on my desktop. I am visiting my daughter and want to install it on my laptop so I can work while I am there. I understand that you can have the program on a second computer like a laptop as long as you don't use both computers at