Skip to Content
author's profile photo Former Member
Former Member

Logic inside a loop

Hi Everyone.......

Having a simple doubt regarding the looping

I have done this select query

SELECT WF_ID

NODE_ID

WI_ID

TASK_ID

LOG_DATE

LOG_TIME

WI_AGENT

RETURNTYP

LOG_COUNT

FROM SWPSTEPLOG

INTO TABLE lt_SWPSTEPLOG

WHERE wf_id = s_wf_id AND

log_date in s_log AND

wi_agent in s_agent.


After this condition i need to introduce a logic as

-Need to identify the task(task_id)

-From the selected task id of the table SWPSTEPLOG need to check the about the RETURNTYP.

-Say condition wen RETURNTYP = RC or EV .

-The return type RC will represent the Start Date/Time for a specific task, while the return type EV represents the action taken by the user for the previous task, so the Completion Date/Time.


Can any one pls help in this case


Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Posted on Jul 24, 2014 at 11:09 AM

    Meenakshi,

    you can create a internal table copy to access the previous task and use case to check the condition.

    it_swpsteplog_pre[] = it_swpsteplog[].

    * Read selected entries

    loop at it_swpsteplog.

    Check returntype values

    CASE it_swpsteplog-returntyp.

    * Returntyp = RC

    WHEN 'RC'.

    "your logic about Start Date/Time

    * Returntyp = EV

    WHEN 'EV'.

    "your logic about Completion Date/Time

    "read your auxiliar internal table it_swpsteplog_pre

    "to get previous task (example using logic key... or

    "using sy-tabix logic...)

    ENDCASE

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2014 at 11:10 AM

    Hi meenakshi,

    data: wa_SWPSTEPLOG like line of it_SWPSTEPLOG

    loop at lt_SWPSTEPLOG into wa_SWPSTEPLOG.

    case wa_SWPSTEPLOG-RETURNTYP.


    when 'RC'.


    ******* Start Date/Time for a specific task

    you can write actions here

    when 'EV'.

    ******** action taken by the user for the previous task

    you can write actions here

    endcase.

    endloop.

    Regards

    Ashwin kv

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      HI ,

      Thanks for ur reply,

      The return type RC will represent the Start Date/Time for a specific task, while the return type EV represents the action taken by the user for the previous task, so the Completion Date/Time



  • Posted on Jul 24, 2014 at 11:12 AM

    Hi,

    After getting data in internal table

    Read ur internal table no of times according to your requirement.

    Read <itab> into <wa> where task_id = xyz returntyp = 'RC'

    If sy-subrc eq o.

    starttime =

    endif.

    Read <itab> into <wa> where task_id = xyz returntyp = 'EV'

    If sy-subrc eq o.

    action taken =

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 24, 2014 at 11:34 AM

    Define your internal table as one the sorted types, use keys TASK_ID and RETURNTYP. Then LOOP at the table and use a logic like

    LOOP AT itab ASSIGNING <fs>.
    AT NEW task_id.
    " initialize a new record in final table (e.g. APPEND INITIAL RECORD ASSIGNING <final>).
    ENDAT.
    " move some other fields in new final table record
    CASE <fs>-returntyp.
    WHEN 'RC'.
    " move log date/time to final table start fields
    WHEN 'EV'.
    " move log date/time to final table end fields
    ENDCASE.
    AT END OF task_id.
    " calculate duration
    ENDAT.
    ENDLOOP.

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2014 at 12:39 PM

    hi

    After getting the start date and time for the RC task, look for the Completion date and time in a subsequent task where:

    WF_ID from RC record = WF_ID from EV record

    NODE_ID from RC record = NODE_ID from EV record

    WI_ID from RC record = WI_ID from EV record

    TASK_ID from RC record = TASK_ID from EV record


    how can i achieve this by moving from one record to another

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.