cancel
Showing results for 
Search instead for 
Did you mean: 

Printing Personal number (PERNR) IN FOUR COLUMNS USING SMARTFORM

Former Member
0 Kudos

<<Mobile phone number removed - Read the Rules of Engagement>>

Hai Friends,

I have a problem with SMART FORM .

I tried to print PERNR Number of PA00002. I Need only one varible its printing fine. its printing 15 personal numbers per page.

my requirement is , it should print 60 personal numbers on a page.

i am giving sample here.now its print like bellow.

20001

20002

.

.

20015 after 15 rows its going to next page. but i want like bellow

20001 20016 20031 20046

20002 20017 20032 20047

20015 20030 20045 20069

OR

20001 20002 20003 20004

20005 20006 20007 20008

20009 20010 20011

Please let me know if any one knows this scenario. i am thankful to you.

Thanks and Regards,

BALU

<<Mobile phone number removed - Read the Rules of Engagement>>

Edited by: Matt on Nov 20, 2008 9:34 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

In your Driver program or smartform, create a internal table with structure as follows;

Pernr1 Pernr2 Pernr3 Pernr4

and fill it using Loop at existing internal table.

Now you can create a table in a window and print the data in four columns.

Regards

Karthik D

P.S.: Dont provide contact information like mobile/email other than in Business card.

Former Member
0 Kudos

Hai Karthik,

Thanks alot for your quick reply. i tried with your logic. its working for 4 numbers and mulitple of 4. if i give 20001 to 20004 or 20008 or 20012 in selection screen its working fine.

if i gave 20001 to 20003. its not printing. if i give 20001 to 20010, its printing till 20008 not printing 20009 and 20010.

i am sedning the code. pls can you tell me where is mistake. i am appending itab2 at last column.i think thats why its comming like this.but if i append after end of 4 th column its print only first column and remaining values are zero.

REPORT ZPPEMP_NUMBERS.

TABLES: PA0002.

SELECT-OPTIONS: S_PERNR FOR PA0002-PERNR.

DATA: FM_NAME TYPE rs38L_fnam,

T_PA0002 LIKE STANDARD TABLE OF PA0002 WITH HEADER LINE.

TYPES: BEGIN OF TY_EMP,

COL1 LIKE PA0002-PERNR,

COL2 LIKE PA0002-PERNR,

COL3 LIKE PA0002-PERNR,

COL4 LIKE PA0002-PERNR,

END OF TY_EMP.

DATA: I_EMP TYPE STANDARD TABLE OF TY_EMP WITH HEADER LINE.

DATA; G_COUNT.

G_COUNT = 0.

START-OF-SELECTION.

SELECT * FROM PA0002 INTO TABLE T_PA0002 WHERE PERNR IN S_PERNR.

LOOP AT T_PA0002.

G_COUNT = G_COUNT + 1.

IF G_COUNT = 1.

I_EMP-COL1 = T_PA0002-PERNR.

ENDIF.

IF G_COUNT = 2.

I_EMP-COL2 = T_PA0002-PERNR.

ENDIF.

IF G_COUNT = 3.

I_EMP-COL3 = T_PA0002-PERNR.

ENDIF.

IF G_COUNT = 4.

I_EMP-COL4 = T_PA0002-PERNR.

APPEND I_EMP.

CLEAR: G_COUNT, T_PA0002.

ENDIF.

ENDLOOP.

I am passing I_EMP table to FORM using CALL FUNCTION FM_NAME.

Hai karthik please can look in to this.

Hai viswa thanks for your reply , karthik solution is working almost.

thank you guys

Former Member
0 Kudos

Do a little modification of your loop as follows;

Data : rec_count TYPE i.
DESCRIBE table T_PA0002 LINES rec_count.
LOOP AT T_PA0002.

G_COUNT = sy-tabix mod 4.

CASE g_count.
	WHEN 1.
    I_EMP-COL1 = T_PA0002-PERNR. 
	WHEN 2.
    I_EMP-COL2 = T_PA0002-PERNR.
	WHEN 3.
    I_EMP-COL3 = T_PA0002-PERNR.
  WHEN 0.  
    I_EMP-COL4 = T_PA0002-PERNR.
ENDCASE.

IF g_count EQ 0. " Everytime all the fields are filled, append and clear
    APPEND I_EMP.
    CLEAR I_EMP. 
ENDIF.
IF g_count GT 0 AND SY-tabix EQ rec_count. "if 7 records are there, final three fields will be appended here
    APPEND I_EMP.
ENDIF.
ENDLOOP.

Check and revert back.

Regards

Karthik D

Answers (2)

Answers (2)

Former Member
0 Kudos

Hai Karthik,

Thanks alot. YOUR SOLUTION IS WORKING PERFECTLY.

really thankful to you.

its printing all the numbers now .

in smartform i have given col1 col2 col3 col4 .if i give 1 to 10 in selection-screen . its printing till 10 after its printing 2 extra columns like 00000 00000.

is there anything to remove that also?

Any how once again thanks karthik.

Thanks

krishna

Former Member
0 Kudos

Hi,

While using the workarea field in the text element use like;

&wa_itab-col1(CZ)&

Likewise use (CZ) for all textelements printing PERNR.

This will solve your problem.

Regards

Karthik D

Former Member
0 Kudos

Actually,

You can go with karthik's answer. Also, I dont know If the solution I am going to present would work...but can be tried out.

Create a template....and have one line type...divide the width of the window into 4 columns. Then..create four columns.

Now, create 4 text elements...then in the output options you will give line as 1 and column 1,2,3,4 respectively for all the four columns.

Now, give the variable pernr in all the four columns. Now,using sy-tabix or index...write conditions in the text element...like that in the first column,only the first 15 should print and again in the second text element...next 15...

So, as the index increases...the display also would come. Our SAP server is down..Anyhow even I will work this out.

Regards,

VIshwa.