Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

creating differeNT spool requests based on sorting USING SMARTFORMS

Former Member
0 Kudos
257

hi folks,

I AM PRINITING STATEMENTS USING SMARTFORMS FOR A SERIES OF CUSTOMERS BUT IT HAS TO BE SORTED ACCORDING TO CERTIAN REQS BEFORE GENERATING A SPOOL REQUEST AND PRINTING THEM.

I need your help folks, I do not know how to proceed from here.

I will explain the requirement and the code I have written so far...

first lets say that ACCITAB has the records that are printed in the main window of the form. The accitab has the records for all the customers in a sequence.

For example.... ACCITAB FOR VARIOUS CUSTOMERS LOOK LIKE THIS.

Customer Invoice Date Passed Due

1234 08/25/2005 $1.00

1234 08/26/2005 $1.00

1234 08/27/2005 $1.00

5678 08/21/2005 $1.00

5678 08/22/2005 $1.00

5678 08/23/2005 $1.00

5678 08/24/2005 $1.00

5678 08/25/2005 $1.00

5678 08/26/2005 $1.00

For each customer at the end I will determine

'ztotalamount' (from aging report) and 'zcurrenttotal' (by adding all the numbers form the body)

Now if ztotalamount not equal to 'zcurrenttotal'

then the customers belonging to this category has to separated from the block and the statements of these customers should print in one spool request.

THIS IS THE FIRST IMPORTANT SORTING

WHAT i DID...

IF ZCURRENTTOTAL = ZTOTALAMOUNT.

ZZSORTFLAG = 'II'. ***CREATED A FLAG

ELSE.

ZZSORTFLAG = 'I'.

ENDIF.

if zzsortflag = 'I'.

loop at accitab where accitab-zadvertiser = zzadvertiser AND accitab-zagency = zzbusinesspartner.

Insert lines of accitab into table

final_accitab. *** FINAL_ACCITAB SAME AS ACCITAB

now final_accitab has records for those customers that does not satisfy the condition.

I have to generate separate statements in a single spool request here for these different customers becoz they come under a single category

HOW TO YOU DEVELOP THE CODE HERE???

THANKS FOR YOUR HELP IN THIS REGARD WELL IN ADVANCE..

I KNOW RICH MENTIONED THE USE OF 'OPEN_FORM' ...'CLOSE_FORM' FM BUT I DO NOT KNOW HOW TO USE IT HERE.

VINU

12 REPLIES 12

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
120

I mentioned the OPEN_FORM CLOSE_FORM cause I thought you were doing a sapcript.

Regards

Rich Heilman

0 Kudos
120

If you only need to cut to number page inside one spool, then you can use the NEW-PAGE command.

http://www.sap-img.com/smartforms/smart-006.htm

<i>Forcing a page break within table loop

Create a loop around the table. Put a Command node before the table in the loop that forces a NEWPAGE on whatever condition you want. Then only loop through a subset of the internal table (based on the conditions in the Command node) of the elements in the Table node. </i>

Regards,

Rich Heilman

Message was edited by: Rich Heilman

0 Kudos
120

hi how to use NEW-PAGE commans in smartform to get different pages for different customers?

0 Kudos
120

you need to add a command node and there check the checkbox to trigger a new page.

Vinod_Chandran
Active Contributor
0 Kudos
120

Hi Vinu,

You can do this in two different ways.

1. Do the internal table separation in the print program and call the Smartform twice.

2. OR, the sepeation of internal table logic can be written in the Global Data -> Initialisation tab. Let me explain this logic.

a. Using the smarform interface you have to pass all the records in an internal table.

b. Now use your logic to separate the customers. So you will get the customers that do not satisfy the condition in the itab final_accitab and others in say other_customers.

c. Now use the TABLE node to display the items of the normal customers. ie from itab other_customers. Hope this can be continues. If you need page break for each customer then please let me know, I can give you the logic.

d. Use the COMMAND node to do an explicit page break after the first TABLE node.

e. Now use the TABLE node to display the itab final_accitab to display the customers who does not fall in the normal category.

Hope this will help you.

Thanks

Vinod

0 Kudos
120

thanks for your help. I think you can lead me through this...

Let me explain to you the complete sorting process here.

Up till now, I run the ABAP print program for a given range of customers, it runs through the loop and the data gets stored in 'accitab' for all the customersin a sequence,

Now the printing of statements depends ona sorting procedure

1. If the 'zcurrenttotal' and 'ztotalamount' that is calculated for every customer does not match, these set of customers have to be kicked out into a separate group first.

2. if the customer( invoices)carries a flag called special handling' in his records those group of customers have to be grouped and kicked out second

In both these cases the number of pages or anything else does not matter and they are of highest priority.

Now,

3. those customers (invoices) that have a less total balance $10 or less have to be grouped and kicked out next (for this ... I know I have to take 'ztotalamount' to evaluate it...)

4. those customers (invoices) that have zero balance have to be grouped and kicked out separately

5. those customers whose invoice does not exceed more than a single page are next,

6. those customers whose invoice does have 2-5 pages are next,

7. those customers whose invoice does more than 5 pages are the last

From 2 to 7 the totals are matching but have special criteria

This is the sort order that the statements are to be printed.

Working on this process I went ahead and worked on

looping the data in 'ACCITAB' and reading into a different internal table like 'final_accitab' -it was my starting point.

I need help as how to go ahead from here,

Please help me in this regard...

Thanks in advance

Vinu.

0 Kudos
120

Hi Vinu,

You have all the customers in the internal table accitab.

Let us start from here. Now we need to group the customers. For this it would be better to have another field in the itab accitab called group (of type n, length 1).

Now loop through accitab and for each customer determine in which group he belongs to. But for group 5,6 and 7 you have to find out how many lines can be printed in a page. Using the number of lines you can determine the number of pages. Hope this you can handle.

So after the above step, for all the customers we have the group.

Pass this to the Smartform using interface parameter TABLE.

Inside the Smartform we can display the customer items using the TABLE node. But, I think, you need an explicit page break for each group. This cannot be done inside the TABLE node. So for this purpose we have to use the LOOP node.

First create a LOOP node. This will loop 7 times. I think you have to have another simple internal table (e.g I_CUSTGRP) with only one field called GROUP and 7 records in that. The value of group is 1 to 7.

Inside the LOOP node create a TABLE node. Give the internal table accitab here and also give a work area.

In the WHERE condition give the condition

GROUP = I_CUSTGRP-GROUP

Because of this WHERE condition each time only the relevant group is selected.

After the TABLE node, inside the LOOP node, create a command node. In it select the 'new page' check box and give a page.

Here the processing will be like this. The LOOP node will loop through the I_CUSTGRP internal table. It will select the group from 1. Then the control will come to the TABLE node. Because of the WHERE condition, only customers with group = 1 will be selected and displayed. After all the customers of group 1 is displayed, the control will come out of the TABLE node. The next node is the COMMAND node. In it we have specified next page. So a page break will happen. Now the control will go back to the LOOP statement and selects the next record. i.e. group 2 and the TABLE node will process customers with group 2. This will go ahead upto group 7.

Hope this logic will work.

Kindly reward points if the answer is helpful.

Thanks

Vinod

0 Kudos
120

Thanks Vinod, it really helped. I shall award the points and I will start on that and will get back to seek your help in this.

0 Kudos
120

Had a question here?

for each type of sorting I can arrive at the conclusion only after populating all the records for a customer into the itab 'accitab' then checking as to how many pages or zero balance or matching balance can be checked.

Then I will be able to determine which group it belongs to - after that how can I update the same itab 'accitab' with the grouping type

otherwise, Am I suppose to read the data from 'accitab' into a new itab say ' final_accitab' with the group field declared in it and assign the grouping type to each customer in the new table ?

Then pass ' final_accitab' into the smartform and proceed from there.

Your suggesstions on this...

Thanks in advance

0 Kudos
120

Hi Vinu,

You will be ok with that logic. The aim is to get the field GROUP filled and pass to the Smartform.

Thanks

Vinod

0 Kudos
120

Also,

not to forget 'accitab' has data to several lines for each customer.

For example.... ACCITAB FOR VARIOUS CUSTOMERS LOOK LIKE THIS.

Customer Invoice Date Passed Due

1234 08/25/2005 $1.00

1234 08/26/2005 $1.00

1234 08/27/2005 $1.00

5678 08/21/2005 $1.00

5678 08/22/2005 $1.00

5678 08/23/2005 $1.00

5678 08/24/2005 $1.00

5678 08/25/2005 $1.00

5678 08/26/2005 $1.00

7655 08/24/2005 $5.00

7655 08/25/2005 $7.00

7655 08/27/2005 $2.00

7655 08/27/2005 $1.00

7655 08/28/2005 $1.00

7655 08/30/2005 $1.00

suggesstions....

Thanks in advance..

0 Kudos
120

Hi Vinu,

I do not think you have to check the customers in all the line items. Sort the itab based on customer and take the first line item of that customer, then find out in which group he belongs to and then update all the line items of that customer with the group.

Thanks

Vinod