cancel
Showing results for 
Search instead for 
Did you mean: 

ALV list To SmartForm

Former Member
0 Kudos

Hi all,

I wrote an ABAP report Z_ALV_MYPC showing an internal table in ALV list.

Now I want to create another Z-report Z_SF_MYPC that prints data from the same internal table using SmartForm.

I Not experience with SmartForm and ask you to help. My doubts are many.

Here is a snippet of my Z_ALV_MYPC program:

TYPES: BEGIN OF ty_myProfitCenter,

PRCTR TYPE CEPCT-PRCTR,

LTEXT TYPE CEPCT-LTEXT,

BUKRS TYPE CEPC-BUKRS,

END OF ty_myProfitCenter.

DATA: i_myProfitCenter TYPE STANDARD TABLE OF ty_myProfitCenter INITIAL SIZE 0,

wa_myProfitCenter TYPE ty_myProfitCenter.

....

form GetProfitCenerName.

DATA: lc_PRCTR_Z1 TYPE FAGLFLEXA-PRCTR VALUE '0000522%', lc_PRCTR_Z2 TYPE FAGLFLEXA-PRCTR VALUE '0000532%'.

DATA: lc_RBUKRS TYPE FAGLFLEXA-RBUKRS VALUE 'ABC', lc_SEGMENT TYPE FAGLFLEXA-SEGMENT VALUE 'DEFG',

SELECT m1PRCTR m1LTEXT FROM CEPCT AS m1 JOIN CEPC AS m2 ON m1PRCTR = m2PRCTR INTO CORRESPONDING FIELDS OF TABLE i_myProfitCenter WHERE m2KOKRS = lc_RBUKRS AND m2SEGMENT = lc_SEGMENT AND ( m2PRCTR LIKE lc_PRCTR1 OR m2PRCTR LIKE lc_PRCTR2).

SORT i_myProfitCenter BY PRCTR.

endform.

For example, I want to print with SmartForms PRCTR fields, LTEXT and BUKRS from table i_myProfitCenter of type ty_myProfitCenter (my needs are more complex, but to understand SmartForm, I limit myself to this).

1. Maybe I say something stupid, but where there are more than one way to do, I like to write more possible code in ABAP program and less possible set the parameters in SmartForm (for example in the Global Setting: Form attributes, form interface, Global definitions ....).

2. I analyzed SAP demo program SF_EXAMPLE_01. It is used the internal table of type BOOKINGS TY_BOOKINGS already defined nell'ABAP dictionary. Do I have to write type ty_myProfitCenter in APAP dictionary, or can I do in another way (for example, in my Z-report Z_SF_MYPC)?

3. If not asking too much, could explain step-by-step as i do?

Thanks in advance

Serena

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I'm trying to simplify the my question:

How i can pass data from the internal table i_myProfitCenter, from my program Z_ALV_MYPC to SmartForm?

TYPES: BEGIN OF ty_myProfitCenter,

PRCTR TYPE CEPCT-PRCTR,

LTEXT TYPE CEPCT-LTEXT,

BUKRS TYPE CEPC-BUKRS,

END OF ty_myProfitCenter.

DATA: i_myProfitCenter TYPE STANDARD TABLE OF ty_myProfitCenter INITIAL SIZE 0.

Former Member
0 Kudos

Hi..

Just follow the follwing steps.

1. Create a structure with required fields : PRCTR, LTEXT and BUKRS in SE11.

2. Create a tabletype using the above created structure.

(Above two steps are required as the table/ stucture you use in internal ABAP prog are not recognized in smartforms).

3. Declare an internal table in Smartform's Global Settings -> Form Interface -> Tables, with type <created table type>.

(Thus your internal table shall be imported into smartform, however for its display, you have to create table in main window.)

4. Call FM SSF_FUNCTION_MODULE_NAME and pass smartform name to it and get the importing parameter FM_NAME.

5. Execute the smartform and get the Fuction module name. Call this FM in your ABAP prog and pass the internal table to it.

Change the Called function's name from something like this '/1BCDWB/SF00000014' to SF_NAME.

Regards,

Karthik

Answers (3)

Answers (3)

Former Member
0 Kudos

I CREATED HEADER DATA IN ALV AND TO DISPLAY THE ITEM DATA OF CORRESPONDING FIELDS I USED SMARTFORMS.

[ GOTO SE11 AND CREATE A STRUCTURE ZWAVBAP CONTAINING VBELN POSNR MATNR ARKTX FIELDS.....

AND ALSO CREATE A TABLE TYPE ZITVBAP AND PASS THEM IN THE SMARTFORM ]

THIS WORKED FOR ME..............

&----


*& Report ZPRG_GRID_EX1

*&

&----


*&

*&

&----


REPORT ZPRG_GRID_EX1.

TYPE-POOLS : SLIS.

TYPES:BEGIN OF TY_VBAK,

VBELN TYPE VBELN,

ERNAM TYPE ERNAM,

ERDAT TYPE ERDAT,

VBTYP TYPE VBTYP,

END OF TY_VBAK.

DATA: IT_VBAK TYPE STANDARD TABLE OF TY_VBAK,

WA_VBAK TYPE TY_VBAK,

IT_VBAP TYPE ZITVBAP, "CREATE TABLE TYPE IN SE11 AND PASS IN SMARTFORM> FORM INTERFACE

WA_VBAP TYPE ZWAVBAP. "CREATE STRUCTURE IN SE11 AND PASS IN SMARTFORM> GLOBAL DEFINITIONS

DATA:IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT LIKE LINE OF IT_FIELDCAT,

V_VBELN TYPE VBAK-VBELN.

DATA: V_PRG TYPE SY-REPID.

SELECTION-SCREEN BEGIN OF block B1 with FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_VBELN FOR V_VBELN.

SELECTION-SCREEN END OF BLOCK B1.

start-of-selection.

SELECT VBELN ERNAM ERDAT VBTYP INTO TABLE IT_VBAK

FROM VBAK

WHERE VBELN IN S_VBELN.

WA_FIELDCAT-COL_POS = '1'.

WA_FIELDCAT-FIELDNAME = 'VBELN'.

WA_FIELDCAT-OUTPUTLEN = '20'.

WA_FIELDCAT-SELTEXT_M = 'SALES NUMBER'.

WA_FIELDCAT-HOTSPOT = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '2'.

WA_FIELDCAT-FIELDNAME = 'ERNAM'.

WA_FIELDCAT-OUTPUTLEN = '20'.

WA_FIELDCAT-SELTEXT_M = 'NAME'.

WA_FIELDCAT-HOTSPOT = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '3'.

WA_FIELDCAT-FIELDNAME = 'ERDAT'.

WA_FIELDCAT-OUTPUTLEN = '20'.

WA_FIELDCAT-SELTEXT_M = 'DATE'.

WA_FIELDCAT-HOTSPOT = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '4'.

WA_FIELDCAT-FIELDNAME = 'VBTYP'.

WA_FIELDCAT-OUTPUTLEN = '20'.

WA_FIELDCAT-SELTEXT_M = 'TYPE'.

WA_FIELDCAT-HOTSPOT = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

V_PRG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_PRG

I_CALLBACK_USER_COMMAND = 'INTERACTIVE'

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = IT_VBAK

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

********************************************

SMARTFORM FOR SECONDARY LIST**********************

DATA: V_PRGNAME TYPE TDSFNAME.

FORM INTERACTIVE USING LF_UCOMM TYPE SY-UCOMM

LF_FIELD TYPE SLIS_SELFIELD.

DATA: V_VBELN TYPE VBELN.

CASE LF_UCOMM.

WHEN '&IC1'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = LF_FIELD-VALUE

IMPORTING

OUTPUT = V_VBELN

.

SELECT

VBELN POSNR MATNR ARKTX FROM VBAP INTO TABLE IT_VBAP

WHERE VBELN EQ V_VBELN.

V_PRGNAME = 'ZSMART_EX'. "SMARTFORM

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = V_PRGNAME

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = V_PRGNAME

  • EXCEPTIONS

  • NO_FORM = 1

  • NO_FUNCTION_MODULE = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION V_PRGNAME

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

IT_VBAP = IT_VBAP

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

  • EXCEPTIONS

  • FORMATTING_ERROR = 1

  • INTERNAL_ERROR = 2

  • SEND_ERROR = 3

  • USER_CANCELED = 4

  • OTHERS = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDCASE.

ENDFORM.

Edited by: chelives on Oct 10, 2011 6:45 AM

Former Member
0 Kudos

Hi ,

Isteead of this below Structure , create on structure in SE11 (zz_myProfitCenter)

TYPES: BEGIN OF ty_myProfitCenter,

PRCTR TYPE CEPCT-PRCTR,

LTEXT TYPE CEPCT-LTEXT,

BUKRS TYPE CEPC-BUKRS,

END OF ty_myProfitCenter.

assume that u r final data in internal table

it_myprofitcenter

Just pass that final internal table to the smartform

Same thing u define as the internal table with the above structure (zz_myProfitCenter) in the form stributes in the smartforms

Let me know if you have any concerns....

Regards,

Lokesh .

Former Member
0 Kudos

Hi,

i think you want to do it with your own interest...

just for the sake of your own interest try this..

create a program, facilitate two radio buttions in that one for allowing the user to view the output in ALV format.. and one for allowing the user to see the output in smartfrom...write the logic according to the user selection... but here you can execute your smartform through program only instead of from transaction..

Hope this will help you.

Regards,

Kiran

Former Member
0 Kudos

Yes, i would do just that.

But i do not know how to do what you say "but here you can execute your smartform through program only instead of from transaction.." Could you explain?

Former Member
0 Kudos

hi,

In general we excute the smart forms throgh transaction by attaching smartform name and its driver program to the NACE transaction..

but in your case its not possible...

hope this will help you

regards,

kiran