cancel
Showing results for 
Search instead for 
Did you mean: 

Reading record line by line

Former Member
0 Kudos

Hello,

I have a requirement where one task gets me list of approvers. Lets say there are 5 approvers and now read this list of approvers one by one and email them. So the email goes to 1st approver and he approves, then read second record and email him -> approves and then read the 3rd record and email him. and so on till the last.

My ques is how to READ already populated table one by one ? Is there anything like sy-index which will let me read the record in sequence or i need to have a counter of my own ? I am using untill loop where i am planning to implement this scenario.

Can you please help me in this regard.

Regards,

Anurag

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

To read the multiline container in workflow please see the below the link.

http://wiki.sdn.sap.com/wiki/display/ABAP/AccessingSingleEntryfromMulti-line+Element

Thanks and regards,

SNJY

former_member185167
Active Contributor
0 Kudos

Yes, that's a better idea, use a loop and access &VAR1[&VAR2&]&

Former Member
0 Kudos

Rick,

If i make one method .... which can read the table and get me line count of table entries but when i code inside this method it does not recongnise the internal table for which i need to get line count...what should be done for this ?

former_member185167
Active Contributor
0 Kudos

Hello,

You'd have to pass that table in as a parameter.

But it's better to follow the way it's done in the link already provided:

http://wiki.sdn.sap.com/wiki/display/ABAP/AccessingSingleEntryfromMulti-line+Element

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hi Anurag,

I have the same requirement & I have achieved it as below,

1. Lets assume that the name of the multiline container that has several approvers is multiapp.

2. Write a background method in a BOR with code as below to find the no of records in MULTIAPP.

DATA: LT_MULTIAPP TYPE TABLE OF SWHACTOR,
LV_COUNT TYPE I.

" In below line I am getting multiapp value into local variable
SWC_GET_TABLE CONTAINER 'MULTIAPP' LT_APP.
" In below line I Find the count of records
DESCRIBE TABLE LT_APP LINES LV_COUNT
"In below line I pass the record count back to workflow
SWC_SET_ELEMENT CONTAINER 'COUNT' LV_COUNT.

" From above you will see that the BOR method will have MULTIAPP as importing parameter & COUNT as exporting parameter.

3. Call this BOR method in a background activity step.

4. In workflow container create 2 elements namely COUNT (to hold the value of record count from BOR method --> datatype : int2) & INDEX (to access each record of MULTIAPP using index --> datatype : int2. Set the initial value of INDEX as 1 in the initial value tab ). Create 1 more container element of data type SWHACTOR to hold the current approver value. Let us call it as CURRAPPROVER.

5. Now create a container operation in workflow & give values as below,

RESULT ELEMENT   CURRAPPROVER
ASSIGNMENT         =
EXPRESSION         &MULTIAPP[INDEX]&    (Select MULTIAPP value from F4 help. Then change it manually as &MULTIAPP[INDEX]&. This means that record from MULTIAPP will be placed into CURRAPPROVER index wise)
OPERATOR      Assignment

6. Insert the approval step (either activity or user decision based on your requirement and give &CURRAPP& as the agent using Expression option)

7. Now again insert a container operation to increment the value of INDEX by 1. Place the 2 container operations & 1 approval step within a loop which has condition as Loop until (INDEX > COUNT).

This perfectly works !! Let me know in case of any issues.

Regards,

Bharath

Edited by: bharath padmanabhan on Jun 21, 2011 11:43 AM

Edited by: bharath padmanabhan on Jun 21, 2011 11:44 AM

Edited by: bharath padmanabhan on Jun 21, 2011 11:45 AM

former_member185167
Active Contributor
0 Kudos

Hello,

I assume you mean workitem instead of email.

There may be a simpler way of doing it but one way is to create a method (you could make it a generic one) to which you supply a list of agents and an index value, and it returns the agent at that number in the list. Have your loop increase the index.

regards

Rick Bakker

hanabi technology