stecorp
2nd April 2013, 12:51
I created the custom report to display the number of records based on the user selection. Now the problem is when I output the report, it is displaying only one record in each page.

Where can I configure the number of records to display in one page and also how can I set the report to display in groups wise. eg., Start the new page for each business Partner.

Please anybody help to solve....

mark_h
2nd April 2013, 14:45
All of this can be done in the maintain reports session:
(1) Make sure the page length and margins are correct on the report.
(2) Make sure you did not accidently click the start new page on the detail layout.
(3) Sort the report by business partner, insert a layout for business partner. Then click to the Page button for that layout.

At least this is how I would do it for 4c4. Not sure about LN. Also for (1) above you need to check the device also.

stecorp
3rd April 2013, 03:48
Hi Mark,

Thank you for your support.

I checked the details you specified in point 1& 2. No issues in it.

Let me to explain in detail.

I just copied the report session from some other session and altered the script. After changing the script it used to display some 11 records in one page. After changing the select statement, now it is only displaying one record in one page but it includes some additional blank lines in each page.

Following are my code...

I have also attached the report screenshot for your referrence..


on.choice:

|# initialize values
init.val()

|------------------------------------------------------------
| 2.2.1 Open Report
|------------------------------------------------------------
spool.rep = spool.open( REP_CAR_MDL_CON_LVL, spool.device, 1 )
if ( spool.rep = 0 ) then
choice.again()
endif

spool.id = spool.rep
brp.ret = brp.open( REP_CAR_MDL_CON_LVL, spool.device, 1 )

|------------------------------------------------------------
| Set Scenario Report Field
|------------------------------------------------------------
r.plnc = i.plnc
r.plnc.desc = cprpd400.dsca
|------------------------------------------------------------
| 2.2.2 Set Period
|------------------------------------------------------------
set.period.to.report()

|------------------------------------------------------------
| 2.2.3 Select Output Data From Item, Plan
|------------------------------------------------------------

select a.item, a.plni
from cprpd100 a
where a.item in (select tcibd001.item from tcibd001
where tcibd001._index1 inrange {:i.item.f} and {:i.item.t}
and tcibd001.csig = "40"
and tcibd001._index4 =:i.citg)
and Exists (select tdisa010.item from tdisa010
where tdisa010._index3 = a.item
and tdisa010.stbp inrange {:i.stbp.f}and {:i.stbp.t})

selectdo

|# hold value for next step
i.plni = cprpd100.plni
i.tdisa_item = cprpd100.item

|------------------------------------------------------------
| 2.2.4 Output Car Model Data to Report
|------------------------------------------------------------
func.ret = output.car.data()

if ( func.ret = FUNC_OK ) then
|# do nothing
endif

selectempty

|# no data
mess( MSG_TRG_DATA_NOT_FOUND, 1 )
job.process.error = true
brp.close( brp.ret )
spool.close()
choice.again()

endselect

|------------------------------------------------------------
| 2.2.5 close report
|------------------------------------------------------------
brp.close( brp.ret )
spool.close()

|------------------------------------------------------------
| 2.2.6 End Process
|------------------------------------------------------------
if ( output.cnt = 0 ) then
mess( MSG_REP_NOT_OUTPUT, 1 )
endif


functions:

|------------------------------------------------------------
|** function Description
|** 2.2.2 set period to report field
|------------------------------------------------------------
function void set.period.to.report()
{
cprpddll1015.read.plan.periods(
i.plnc,
dummy_date,
dummy_date,
get.compnr(),
False,
cpcom.yeno.no,
prd.num
)

|------------------------------------------------------------
| 2.3 set period display format data to field
|------------------------------------------------------------
if ( i.pren <= prd.num ) then
r.prid.1 = cprpddll1015.per.description(1,i.pren)
else
r.prid.1 = ""
endif

if ( i.pren + 1 <= prd.num ) then
r.prid.2 = cprpddll1015.per.description(1,i.pren + 1)
else
r.prid.2 = ""
endif

if ( i.pren + 2 <= prd.num ) then
r.prid.3 = cprpddll1015.per.description(1,i.pren + 2)
else
r.prid.3 = ""
endif

if ( i.pren + 3 <= prd.num ) then
r.prid.4 = cprpddll1015.per.description(1,i.pren + 3)
else
r.prid.4 = ""
endif

if ( i.pren + 4 <= prd.num ) then
r.prid.5 = cprpddll1015.per.description(1,i.pren + 4)
else
r.prid.5 = ""
endif

if ( i.pren + 5 <= prd.num ) then
r.prid.6 = cprpddll1015.per.description(1,i.pren + 5)
else
r.prid.6 = ""
endif

if ( i.pren + 6 <= prd.num ) then
r.prid.7 = cprpddll1015.per.description(1,i.pren + 6)
else
r.prid.7 = ""
endif

if ( i.pren + 7 <= prd.num ) then
r.prid.8 = cprpddll1015.per.description(1,i.pren + 7)
else
r.prid.8 = ""
endif

if ( i.pren + 8 <= prd.num ) then
r.prid.9 = cprpddll1015.per.description(1,i.pren + 8)
else
r.prid.9 = ""
endif

if ( i.pren + 9 <= prd.num ) then
r.prid.10 = cprpddll1015.per.description(1,i.pren + 9)
else
r.prid.10 = ""
endif

if ( i.pren + 10 <= prd.num ) then
r.prid.11 = cprpddll1015.per.description(1,i.pren + 10)
else
r.prid.11 = ""
endif

if ( i.pren + 11 <= prd.num ) then
r.prid.12 = cprpddll1015.per.description(1,i.pren + 11)
else
r.prid.12 = ""
endif
}

|------------------------------------------------------------
|** function Description
|** 2.2.4 output car model data
|------------------------------------------------------------
function long output.car.data()
{
|------------------------------------------------------------
| 2.2.4.1 select output car model data
|------------------------------------------------------------
double dem.amount | amount of estimated demand
dem.amount = 0.0


select cprmp300.plni,
cprmp300.pern,
cprmp300.demf
from cprmp300
where cprmp300._index2 = { :i.plnc,
:i.plni,
""
}
and cprmp300.pern >= :i.pren
and cprmp300.pern <= :i.pren + 11

selectdo
|# add demand to amount
dem.amount = dem.amount + cprmp300.demf

|------------------------------------------------------------
| 2.2.4.2 Set Output car model demand data
|------------------------------------------------------------
if ( cprmp300.pern = i.pren ) then
r.demf.1 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 1 ) then
r.demf.2 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 2 ) then
r.demf.3 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 3 ) then
r.demf.4 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 4 ) then
r.demf.5 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 5 ) then
r.demf.6 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 6 ) then
r.demf.7 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 7 ) then
r.demf.8 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 8 ) then
r.demf.9 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 9 ) then
r.demf.10 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 10 ) then
r.demf.11 = cprmp300.demf
endif

if ( cprmp300.pern = i.pren + 11 ) then
r.demf.12 = cprmp300.demf
endif

selectempty
|# goto next record
return ( FUNC_NG )
endselect

|------------------------------------------------------------
| 2.2.4.3 Check Output car model data
|------------------------------------------------------------
if ( double.cmp( dem.amount, 0.0, DOUBLE_TOLERANCE ) = 0 ) and ( i.zrch = tcyesno.yes ) then
|# goto next record
return ( FUNC_NG )
endif

|------------------------------------------------------------
| 2.2.4.4 Set Output car model data to Report Field
|------------------------------------------------------------
|# Select STBP to Display
select tdisa010.stbp
from tdisa010
where tdisa010.item = :i.tdisa_item

Selectdo
r.stbp = str$( tdisa010.stbp )
selectempty
|# goto next record
endselect

|# Item
r.plni = cprmp300.plni( 13;len(cprmp300.plni) - 12 )

|------------------------------------------------------------
| 2.2.4.5 Output report
|------------------------------------------------------------
brp.ready( brp.ret )
output.cnt = output.cnt + 1

return ( FUNC_OK )

}

mark_h
3rd April 2013, 15:34
Here is how I would approach it since I do not readily see an issue - I would first remove the change to the select and make sure it runs exactly like the original report. If it does then you know the issue is the change in the select. Then point out the change you made in the select. Maybe someone will see something I don't see.

Now if you removed the code and it still printed wrong - then something did not get cloned completely. In that case just compare the reports and see if you can identify where the issue is.

stecorp
4th April 2013, 11:07
Hi Mark,

Thank you for your suggestions, I will do it as per your suggestions, since I changed all the tables and fields, it takes some time.

I also asked my vendor for this issue, will let you know once I resolve the problem.

stecorp
8th April 2013, 09:58
Hi Mark,

I found the issue. Actually the issue is not with the script, it was with the Report. Since I copied the script, in the Before Field, the Mandatory field - "Field Name" was the sort filter and page break. It was mentioned as cprpd100.item, so for each item it breaks the page and starts in a new page. Now I changed to Ship to Business Partner, then only breaks when the next business partner starts.

Thank you for your support.