cancel
Showing results for 
Search instead for 
Did you mean: 

Report - Logic needed

former_member194669
Active Contributor
0 Kudos

I have to print a ordinary classical report in this format.

I need print a report that material wise material text needs to be printed in tabular format.

Scenarios:

1. Material 12345 have 85 lines ,then first 60 lines to printed in left and balance 20 lines to be printed in the right,

2. Material 12345 have 140 lines then first 60 lines to be printed in left and next 60 lines to be printed in the right and

balance 20 lines printed in next page left.


Material Number : 12345
XXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX

" --> Page Break Here

Material Number : 12346
XXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX      
XXXXXXXXXXXXXXXXXXXX      
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX

PS please donot suggest to print using sapscript or smartform

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can try like below:

I suppose you would have all the lines in an internal table with text like below:


Now you can loop on this table and create two internal tables based on the number of lines you need to print on the right handside in the above example in loop after first six loop assign to the second internal table with index field like below:

oop on it_mat.

at new materail.

lv-cnt = 70.

endat.

if sy-tabix > 6.

move-corresponding it_mat to it_tab2.

it_tab2-sr = lv_cnt.

append it_tab2.

lv_cnt = lv_cnt + 10.

else.

move-corresponding it_mat to it_tab1.

append it_tab1.

endloop.

and then you can do like below to write on the screen:

loop on it_tab1.

at new material number.

lv_cnt = 70.

if lv_first is initial

lv-first = 'X'.

else.

new-page.

endif.

write:/1 Material Number.

endat.

write:/1 Material Text.

read table it-tab2 with key material = it-tab1-materail

sr = lv_cnt.

if sy-subrc = 0.

write:30 it_tab2-text.

lv_cnt = lv_cnt + 1.

endif.

endloop.

{code]

Regards,

Himanshu

Answers (5)

Answers (5)

former_member194669
Active Contributor
0 Kudos

Thankyou All,

Problem solved by creating a output internal table with columns


data : begin of i_output_1 occurs 0.
data : matnr like mara-matnr.
data : mtext_1(40) type c,
data : mtext_2(40) type c,
data : end of i_output_1.
...
loop at i_output.
  CALL FUNCTION 'RKD_WORD_WRAP'
  EXPORTING
    textline                  = i_output-mtext
   DELIMITER                 = ' '
   OUTPUTLEN                 = 40
 TABLES
   OUT_LINES                 = text_table
...
Fill the I_OUTPUT_1 table and Print with control statement AT END OF

Thanks

Former Member
0 Kudos

Hi ARS,

I developed a scenario as your and figured out a solution .

I create a internal table with two fields.

text1 and text.

data of internal table t_test is as follows---->>>

text1 text

1 1

1 2

1 3

1 4

1 5

1 6

....

.....

....

....

1 80

2 1

2 2

2 3

2 4

2 5

2 6

......

......

......

......

2 140

lets assume t_test- text1 entries as ur material '1' and '2'.

and t_test-text entries as ur material text description lines, for material 1 there are 80 lines and for material 2 there are 140 lines.

I wrote following code to get the output as u desired.....i create and tested at our IDES, and gives output exactly the same as u wanted.


REPORT  ZTEST_MYTEST1.

data: begin of t_test occurs 0,
      text1 type i,
      text type i,
      end of t_test.
data: wa_test like t_test.
DATA: L_TABIX TYPE SY-TABIX.
DATA: CNT TYPE I.

do 2 times.
wa_test-text1 =  wa_test-text1 + 1.
CLEAR wa_test-text.
IF wa_test-text1 = 1.
  do 80 TIMES.
  wa_test-text = wa_test-text + 1.
  APPEND wa_test to t_test.
  enddo.
ELSE.
  do 140 TIMES.
  wa_test-text = wa_test-text + 1.
  APPEND wa_test to t_test.
  enddo.

ENDIF.
ENDDO.

*****Till Now i just created a internal table as ur format and filled it with similar kind of data, now lets see the code to output*******

clear wa_test.
loop at t_test into wa_test.
 CNT = CNT + 1.
  at new text1.
  CLEAR CNT.
  CNT = CNT + 1.
  NEW-PAGE.
  BACK.

  write : wa_test-text1.
  ULINE.
  ENDAT.
*  RESERVE 60 LINES.
  IF CNT <= 60.
    WRITE /1(10) wa_test-text.
    IF CNT = 60.
      BACK.
      WRITE /.
      WRITE /.
    ENDIF.
  ELSEIF CNT >= 61 AND CNT <= 120.
    WRITE /13(10) wa_test-text.
    IF CNT = 120.
      NEW-PAGE.
      BACK.
*      WRITE /.
*      WRITE /.
    ENDIF.
  ELSEIF CNT > 120.
    WRITE /1(10) wa_test-text.
   ENDIF.

endloop.

Copy the above program and run to see the output.

This will definitely resolve your issue.

Regards,

Akash Rana

Edited by: AKASH RANA on Aug 12, 2009 11:51 PM

Edited by: AKASH RANA on Aug 12, 2009 11:53 PM

guilherme_frisoni
Contributor
0 Kudos

Hi,

try something like this:

assuming you have a table for material texts IT_TEXT.


DATA: l_lines_p_page TYPE i value 60,
     ll_right_line TYPE i.
DO.

  "Loop reading left column
  LOOP AT it_text into ls_text_left FROM 1 TO l_lines_p_page. 
    l_right_line = sy-tabix + l_lines_p_page.
    "Read corresponding right column
    CLEAR ls_text_right.
    READ TABLE it_text into ls_text_right index l_right_line.

    WRITE: ls_text_left,
           space,
           ls_text_right.
    WRITE /.
  ENDLOOP.

  "Delete first N lines
  DO l_lines_p_page TIMES.
    DELETE it_text INDEX 1.
  ENDDO.
  
  IF it_text IS INITIAL.
    CONTINUE. "Exit DO.
  ENDIF.
ENDDO.

Hope can help you,

Frisoni

Former Member
0 Kudos

put two columns in your internal table.

while passing values (looping in the table) check the tabix or inserting number. if thats less than equal to 60 pass it in the first field and keep appending, if greater than 60 then keep updating that (rownumber- 60)th row passing the field into the 2nd field of the table.

reset the count when its 120( or even multiple of 60). again follow the same process.

hope this helps

Former Member
0 Kudos

I assume the lines are of fixed length or already correctly formatted in an internal table?

Rob

former_member194669
Active Contributor
0 Kudos

Rob,

Lines are fixed length left = 40 right = 40

But internal table have length of 80 (Output table )


1234567890XXXXXXXXXX1234567890XXXXXXXXXX1234567890XXXXXXXXXX1234567890XXXXXXXXXX

needs to be


1234567890XXXXXXXXXX1234567890XXXXXXXXXX       1234567890XXXXXXXXXX1234567890XXXXXXXXXX
1234567890XXXXXXXXXX1234567890XXXXXXXXXX
1234567890XXXXXXXXXX1234567890XXXXXXXXXX
1234567890XXXXXXXXXX1234567890XXXXXXXXXX

a®s

Edited by: a®s on Aug 12, 2009 3:14 PM

Former Member
0 Kudos

Are the X's spaces or other text? Can you easily split the lines where you need to?

I think that you first need to create an internal table of length 40 that has the data in the correct sequence. and then use read ahead logic to read it and format the page.

Rob

former_member194669
Active Contributor
0 Kudos

There is not spaces X mentioned are text.

Sandra_Rossi
Active Contributor
0 Kudos

What is exactly the issue? (how to count the number of lines till the bottom of page?)