cancel
Showing results for 
Search instead for 
Did you mean: 

problem in getting data in smartform

Former Member
0 Kudos

how to get data from my internal table in smartform, i need data from this table:

DATA: BEGIN OF TBL_CAPACITYTAB OCCURS 0,

ARBPL like CRHD-ARBPL, "Work Centre

AUFNR LIKE AUFK-AUFNR, "SO #

KTEXT LIKE AUFK-KTEXT, "SO Description

VORNR LIKE AFVC-VORNR, "Operation No.

FSAVD LIKE AFVV-FSAVD, "Operation Start

LTXA1 LIKE AFVC-LTXA1, "Operation Description

ANZZL LIKE AFVC-ANZZL, "Staff

DAUNO LIKE AFVV-DAUNO, "Duration

TPLNR LIKE VAFILOA-TPLNR, "Functional Location

USR04 LIKE AFVU-USR04, "Start Km

END OF TBL_CAPACITYTAB.

I already taken this internal table as structure zcapacity.

what should i declare in global settings and form interface..Tell me something to get this internal table data to my form

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

i declared as you said exactly in smartform.........and activated.

now modify the program..so that i can do pass function module and assign that program to output in the smartform.

Should i remove that top-of-page, form printdata, form print_data in the report.....because that will be outputted in the smartform.

please check the errors. thank u so much in sparing your valuable time for me.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

DATA: L_DATE LIKE SY-DATUM,

data lv_index type sy-tabix.

LOOP AT itab into wa.

<b>lv_index = sy-tabix.</b>CONCATENATE 'OR' wa-AUFNR INTO OBJNR.

read table i_jest into w_jest with key

OBJNR = OBJNR.

IF SY-SUBRC <> 0.

DELETE itab <b>index lv_index</b>.

CONTINUE.

ENDIF.

ENDLOOP.

Ya.remove those things.Then after activating the program,give LOCL as Output device and see the print preview.You can see the outputs of the three tables.

If you really want to thank me,could you please reward points by clicking green(6 points),yellow stars(2 points) adjacent to my reply whichever you find useful.That's way to say thanks in SDN.If your problem is solved,click the blue star(10 points) adjacent to reply which solved the problem.

<b>If your problem is solved,reward points for all the useful answers and close the thread.</b>

Former Member
0 Kudos

why u taken wa1, wa2, wa3...

is this line <b>i_jest type standard table of jest.</b>

necessary.. bcoz it showing some error.

Former Member
0 Kudos

<b>Please send me the code exactly same as to print in the smartform... or else what should i do in the smartform in order to print output with the same code.

plz hlp me</b>

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

I declared

data i_jest type standard table of jest ,

because in the following code I am selecting all the records outside the loop in the internal table.As of now,it is not problem.I just did it to improve performance.similarly you should declare

data w_jest type jest.

SELECT * FROM JEST into <b>table i_jest</b>

WHERE STAT NOT IN ('CLSD' , 'TECO' )

AND INACT <> 'X'.

LOOP AT itab into wa.

DATA: L_DATE LIKE SY-DATUM.

CONCATENATE 'OR' wa-AUFNR INTO OBJNR.

read table i_jest into w_jest with key

OBJNR = OBJNR.

IF SY-SUBRC <> 0.

DELETE itab where objnr = wa-objnr.

CONTINUE.

ENDIF.

ENDLOOP.

<b>Are you clear that workarea is needed in Report?

Then proceed as follows:</b>

Smartform:

Form Interface->Tables

itab1 like ZSTRUCT

itab2 like ZSTRUCT

itab3 like ZSTRUCT

Global Definitions

Global Data

wa1 type ZSTRUCT

wa2 type ZSTRUCT

wa3 type ZSTRUCT

create loop

loop->Data

internal table itab1 into wa1

create text element and drag the required fields

create second loop

loop->Data

internal table itab2 into wa2

create text element and drag the required fields

create third loop

loop->Data

internal table itab3 into wa3

create text element and drag the required fields

activate it.

Report:

TABLES : AFIH, " MAINTANCE ORDER TABLE

AUFK, " ORDER MASTER TABLE

AFVGD, " Order:Dialog table for Table AFVG(order operation)

CAUFVD, " Dialog structure for order headers and items

AFKO, " Order header data PP orders

AFVV, " DB structure of the quant values in the operation

AFVC, " Operation within an order

AFVU, " DB structure of the user fields of the operation

ILOA, " PM Object Location and Account Assignment

CRHD, " Work Center Header

JEST. " Individual Object Status

*DATA : ZCAPACITYTAB TYPE ZCAPACITYTAB.

*DATA : BEGIN OF TBL_CAPACITYTAB OCCURS 0,

*

  • INCLUDE STRUCTURE ZSTRUCT.

*

  • END OF TBL_CAPACITYTAB.

&----


&

& Internal Tables &

&----


&

DATA : FNAM TYPE RS38L_FNAM.

data : itab type standard table of ZSTRUCT,

wa type ZSTRUCT,

itab1 type standard table of ZSTRUCT,

itab2 type standard table of ZSTRUCT,

itab3 type standard table of ZSTRUCT,

i_jest type standard table of jest,

w_jest type jest.

&----


&

& Data Definition Include &

&----


&

DATA : CHK1,

DAY_NUM TYPE P,

OBJNR LIKE JEST-OBJNR,

END_DATE LIKE SY-DATUM,

S_DATE LIKE SY-DATUM,

E_DATE LIKE SY-DATUM.

&----


&

& SELECTION SCREEN DESIGN AND SELECTION CRITERIA &

&----


&

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_IWERK LIKE AFIH-IWERK DEFAULT 'N200', "PLANT

P_DATE LIKE SY-DATUM. "SAP CALENDER DAY

SELECT-OPTIONS : S_AUART FOR AUFK-AUART, "Work Order Type

S_ARBPL FOR AFVGD-ARBPL, "operational W.centre

S_TPLNR FOR CAUFVD-TPLNR. "Functional Location

SELECTION-SCREEN END OF BLOCK B1.

&----


&

& AT SELECTION-SCREEN &

&----


&

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

DATUM = P_DATE

IMPORTING

WOTNR = DAY_NUM.

IF DAY_NUM <> 1.

MESSAGE I000(ZICPR).

LEAVE LIST-PROCESSING.

ENDIF.

IF P_DATE < SY-DATUM.

MESSAGE I001(ZICPR).

ENDIF.

&----


&

& START-OF-SELECTION &

&----


&

START-OF-SELECTION.

SET PF-STATUS 'S100'.

END_DATE = P_date + 21.

SELECT AUFK~AUFNR AUFK~KTEXT

AFVV~DAUNO AFVV~FSAVD

AFVU~USR04 AFVC~VORNR AFVC~LTXA1 AFVC~ANZZL

AFIH~IWERK

ILOA~TPLNR

CRHD~ARBPL

INTO CORRESPONDING FIELDS OF TABLE itab

FROM AUFK

JOIN AFKO ON AUFK~AUFNR = AFKO~AUFNR

JOIN AFVV ON AFKO~AUFPL = AFVV~AUFPL

JOIN AFVC ON AFKO~AUFPL = AFVC~AUFPL and AFVV~APLZL = AFVC~APLZL

LEFT OUTER JOIN AFVU ON AFVV~AUFPL = AFVU~AUFPL

AND AFVV~APLZL = AFVU~APLZL

JOIN AFIH ON AFKO~AUFNR = AFIH~AUFNR

JOIN ILOA ON AFIH~ILOAN = ILOA~ILOAN

JOIN CRHD ON AFVC~ARBID = CRHD~OBJID AND CRHD~OBJTY = 'A'

WHERE AFVV~FSAVD >= P_date and AFVV~FSAVD <= END_DATE " '000000500400'

AND AFIH~IWERK = P_IWERK

AND AUFK~AUART IN S_AUART

AND CRHD~ARBPL IN S_ARBPL

AND ILOA~TPLNR IN S_TPLNR.

SELECT * FROM JEST into table i_jest

WHERE STAT NOT IN ('CLSD' , 'TECO' )

AND INACT <> 'X'.

LOOP AT itab into wa.

DATA: L_DATE LIKE SY-DATUM.

CONCATENATE 'OR' wa-AUFNR INTO OBJNR.

read table i_jest into w_jest with key

OBJNR = OBJNR.

IF SY-SUBRC <> 0.

DELETE itab where objnr = wa-objnr.

CONTINUE.

ENDIF.

ENDLOOP.

S_DATE = P_DATE.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 1, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

PERFORM PRINT.

LOOP AT itab into wa WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

append wa to itab1.

PERFORM PRINT_DATA.

ENDLOOP.

ULINE.

**

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 2, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

PERFORM PRINT.

LOOP AT itab into wa WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

append wa to itab2.

PERFORM PRINT_DATA.

ENDLOOP.

ULINE.

***

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 3, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

PERFORM PRINT.

LOOP AT itab into wa WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

append wa to itab3.

PERFORM PRINT_DATA.

ENDLOOP.

ULINE.

***

&----


&

& TOP-OF-PAGE. &

&----


&

*INCLUDE ZUHEADER.

TOP-OF-PAGE.

WRITE 😕 '3 Week Rolling Plan',

/ 'Workcentre : ',TBL_CAPACITYTAB-ARBPL.

SKIP 1.

&----


&

& END-OF-SELECTION. &

&----


&

END-OF-SELECTION.

WRITE:/ SY-VLINE,' FORM NUMBER :',68 SY-VLINE,'WEEKLY PLAN COMMENTS ',

225 SY-VLINE,

/ SY-VLINE, ' ISSUE DATE : ',68 SY-VLINE,225 SY-VLINE,

/ SY-VLINE,' REVISION : ',68 SY-VLINE, 'TEAM LEADER SIGNATURE : ',

225 SY-VLINE.

ULINE AT 0(SY-LINSZ).

&----


*& Form PRINT

&----


  • text

----


FORM PRINT.

WRITE 😕 SY-VLINE,14'SO #',25 SY-VLINE,

29 'SO Description',68 SY-VLINE,

70'Oper',75 SY-VLINE,

77 'Oper Start',88 SY-VLINE,

90 'Operation Description',131 SY-VLINE,

132 'Staff',137 SY-VLINE,

142 'Dur',147 SY-VLINE,

149 'Funct Location ',190 SY-VLINE,

201'Start km',215 SY-VLINE,

218 'Compl',225 SY-VLINE.

uline at 0(sy-linsz) .

ENDFORM. "PRINT

&----


*& Form PRINT_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PRINT_DATA .

WRITE:/ SY-VLINE,TBL_CAPACITYTAB-ARBPL,

TBL_CAPACITYTAB-AUFNR,SY-VLINE,

TBL_CAPACITYTAB-KTEXT,SY-VLINE,

TBL_CAPACITYTAB-VORNR,SY-VLINE,

TBL_CAPACITYTAB-FSAVD,SY-VLINE,

TBL_CAPACITYTAB-LTXA1,SY-VLINE,

TBL_CAPACITYTAB-ANZZL,SY-VLINE,

TBL_CAPACITYTAB-DAUNO,SY-VLINE,

TBL_CAPACITYTAB-TPLNR,SY-VLINE,

TBL_CAPACITYTAB-USR04 ,215 SY-VLINE,220 CHK1 AS CHECKBOX,

225 SY-VLINE.

ENDFORM. " PRINT_DATA

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZSAM1'"name of smartform in capital letter

importing

fm_name = FNAM

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 FNAM

TABLES

itab1 = itab1 "internal table you are passing from program

itab2 = itab2

itab3 = itab3

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.

Activate it.

Former Member
0 Kudos

Hi..

I am getting error:

<b>The data object wa does not have a component called objnr.</b>

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Just modify this.

LOOP AT itab into wa.

DATA: L_DATE LIKE SY-DATUM.

CONCATENATE 'OR' wa-AUFNR INTO OBJNR.

read table i_jest into w_jest with key

OBJNR = <b>wa-OBJNR</b>.

IF SY-SUBRC <> 0.

DELETE itab where objnr = wa-objnr.

CONTINUE.

ENDIF.

ENDLOOP.

Former Member
0 Kudos

<u>modified but still the same error</u>

Former Member
0 Kudos

okay..

leave TBL_CAPACITYTAB1

TBL_CAPACITYTAB2

TBL_CAPACITYTAB3 AND PROCEED......

COMMENT THEM.

there is no use...

Check the output of this report..i need the same exactly in smartform....

Should i create 3 tables in main area

Former Member
0 Kudos

Hai.. exactly i declared the same fields as internal table <b>ZSTRUCT</b>.

I don't want to use workarea, i want to get data in tbl_capacitytab itself.

My program is getting output in standard report. I want this to modify to smartform

My program is like this:

TABLES : AFIH, " Maintance Order Table

AUFK, " Order Master Table

AFVGD, " Order:Dialog table for Table AFVG(order operation)

CAUFVD, " Dialog structure for order headers and items

AFKO, " Order header data PP orders

AFVV, " DB structure of the quant values in the operation

AFVC, " Operation within an order

AFVU, " DB structure of the user fields of the operation

ILOA, " PM Object Location and Account Assignment

CRHD, " Work Center Header

JEST. " Individual Object Status

&----


&

& Internal Tables &

&----


&

DATA: BEGIN OF TBL_CAPACITYTAB OCCURS 0,

ARBPL like CRHD-ARBPL, "Work Centre

AUFNR LIKE AUFK-AUFNR, "SO #

KTEXT LIKE AUFK-KTEXT, "SO Description

VORNR LIKE AFVC-VORNR, "Operation No.

FSAVD LIKE AFVV-FSAVD, "Operation Start

LTXA1 LIKE AFVC-LTXA1, "Operation Description

ANZZL LIKE AFVC-ANZZL, "Staff

DAUNO LIKE AFVV-DAUNO, "Duration

TPLNR LIKE VAFILOA-TPLNR, "Functional Location

USR04 LIKE AFVU-USR04, "Start Km

END OF TBL_CAPACITYTAB.

DATA :TBL_CAPACITYTAB1 LIKE TBL_CAPACITYTAB OCCURS 0 WITH HEADER LINE,

TBL_CAPACITYTAB2 LIKE TBL_CAPACITYTAB OCCURS 0 WITH HEADER LINE,

TBL_CAPACITYTAB3 LIKE TBL_CAPACITYTAB OCCURS 0 WITH HEADER LINE.

&----


&

& Data Definition Include &

&----


&

DATA : CHK1,

DAY_NUM TYPE P, " Gives day no (MON =1)

OBJNR LIKE JEST-OBJNR, " Object number

END_DATE LIKE SY-DATUM, " End date

S_DATE LIKE SY-DATUM, " Start Date

E_DATE LIKE SY-DATUM. " End date

&----


&

& SELECTION SCREEN DESIGN AND SELECTION CRITERIA &

&----


&

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_IWERK LIKE AFIH-IWERK DEFAULT 'N200', "PLANT

P_DATE LIKE SY-DATUM. "Sap Calender Day

SELECT-OPTIONS : S_AUART FOR AUFK-AUART, "Work Order Type

S_ARBPL FOR AFVGD-ARBPL, "operational W.centre

S_TPLNR FOR CAUFVD-TPLNR. "Functional Location

SELECTION-SCREEN END OF BLOCK B1.

&----


&

& AT SELECTION-SCREEN &

&----


&

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

DATUM = P_DATE

IMPORTING

WOTNR = DAY_NUM.

IF DAY_NUM <> 1.

MESSAGE I000(ZICPR).

LEAVE LIST-PROCESSING.

ENDIF.

IF P_DATE < SY-DATUM.

MESSAGE I001(ZICPR).

ENDIF.

&----


&

& START-OF-SELECTION &

&----


&

START-OF-SELECTION.

  • SET PF-STATUS '0100'.

END_DATE = P_date + 21.

SELECT AUFK~AUFNR AUFK~KTEXT

AFVV~DAUNO AFVV~FSAVD

AFVU~USR04 AFVC~VORNR AFVC~LTXA1 AFVC~ANZZL

AFIH~IWERK

ILOA~TPLNR

CRHD~ARBPL

INTO CORRESPONDING FIELDS OF TABLE TBL_CAPACITYTAB

FROM AUFK

JOIN AFKO ON AUFK~AUFNR = AFKO~AUFNR

JOIN AFVV ON AFKO~AUFPL = AFVV~AUFPL

JOIN AFVC ON AFKO~AUFPL = AFVC~AUFPL and AFVV~APLZL = AFVC~APLZL

LEFT OUTER JOIN AFVU ON AFVV~AUFPL = AFVU~AUFPL

AND AFVV~APLZL = AFVU~APLZL

JOIN AFIH ON AFKO~AUFNR = AFIH~AUFNR

JOIN ILOA ON AFIH~ILOAN = ILOA~ILOAN

JOIN CRHD ON AFVC~ARBID = CRHD~OBJID AND CRHD~OBJTY = 'A'

WHERE AFVV~FSAVD >= P_date and AFVV~FSAVD <= END_DATE " '000000500400'

AND AFIH~IWERK = P_IWERK

AND AUFK~AUART IN S_AUART

AND CRHD~ARBPL IN S_ARBPL

AND ILOA~TPLNR IN S_TPLNR.

LOOP AT TBL_CAPACITYTAB.

DATA: L_DATE LIKE SY-DATUM.

CONCATENATE 'OR' TBL_CAPACITYTAB-AUFNR INTO OBJNR.

SELECT SINGLE * FROM JEST

WHERE OBJNR = OBJNR

AND STAT NOT IN ('CLSD' , 'TECO' )

AND INACT <> 'X'.

IF SY-SUBRC <> 0.

DELETE TBL_CAPACITYTAB FROM TBL_CAPACITYTAB.

CONTINUE.

ENDIF.

ENDLOOP.

S_DATE = P_DATE.

E_DATE = S_DATE + 6.

*

SKIP 1.

WRITE:/ ' Week 1, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

PERFORM PRINT.

LOOP AT TBL_CAPACITYTAB WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

PERFORM PRINT_DATA.

ENDLOOP.

ULINE.

**

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 2, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

PERFORM PRINT.

LOOP AT TBL_CAPACITYTAB WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

PERFORM PRINT_DATA.

ENDLOOP.

ULINE.

***

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 3, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

PERFORM PRINT.

LOOP AT TBL_CAPACITYTAB WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

PERFORM PRINT_DATA.

ENDLOOP.

ULINE.

***

&----


&

& TOP-OF-PAGE. &

&----


&

*INCLUDE ZUHEADER.

TOP-OF-PAGE.

WRITE 😕 '3 Week Rolling Plan',

/ 'Workcentre : ',TBL_CAPACITYTAB-ARBPL.

SKIP 1.

&----


&

& END-OF-SELECTION. &

&----


&

END-OF-SELECTION.

WRITE:/ SY-VLINE,' FORM NUMBER :',68 SY-VLINE,'WEEKLY PLAN COMMENTS ',

225 SY-VLINE,

/ SY-VLINE, ' ISSUE DATE : ',68 SY-VLINE,225 SY-VLINE,

/ SY-VLINE,' REVISION : ',68 SY-VLINE, 'TEAM LEADER SIGNATURE : ',

225 SY-VLINE.

ULINE AT 0(SY-LINSZ).

&----


*& Form PRINT

&----


  • text

----


FORM PRINT.

WRITE 😕 SY-VLINE,14'SO #',25 SY-VLINE,

29 'SO Description',68 SY-VLINE,

70'Oper',75 SY-VLINE,

77 'Oper Start',88 SY-VLINE,

90 'Operation Description',131 SY-VLINE,

132 'Staff',137 SY-VLINE,

142 'Dur',147 SY-VLINE,

149 'Funct Location ',190 SY-VLINE,

201'Start km',215 SY-VLINE,

218 'Compl',225 SY-VLINE.

uline at 0(sy-linsz) .

ENDFORM. "PRINT

&----


*& Form PRINT_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PRINT_DATA .

WRITE:/ SY-VLINE,TBL_CAPACITYTAB-ARBPL,

TBL_CAPACITYTAB-AUFNR,SY-VLINE,

TBL_CAPACITYTAB-KTEXT,SY-VLINE,

TBL_CAPACITYTAB-VORNR,SY-VLINE,

TBL_CAPACITYTAB-FSAVD,SY-VLINE,

TBL_CAPACITYTAB-LTXA1,SY-VLINE,

TBL_CAPACITYTAB-ANZZL,SY-VLINE,

TBL_CAPACITYTAB-DAUNO,SY-VLINE,

TBL_CAPACITYTAB-TPLNR,SY-VLINE,

TBL_CAPACITYTAB-USR04 ,215 SY-VLINE,220 CHK1 AS CHECKBOX,

225 SY-VLINE.

ENDFORM. " PRINT_DATA

<b>If u don't mind can u send this report my modifying.. Please...Also tell me what should i declare in smartform after u changing this report.

I don't want wa to be used in this report.

populate the data in same TBL_CAPACITYTAB.

I declared in form interface as:

TBL_CAPACITYTAB LIKE ZSTRUCT</b>

should i modify anymore ........Please help me ..because i have to submit today itself.

I NEED YOUR HELP VERY BADLY

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you want to pass the internal table to smartforms,then you should use internal table and work area separately[that's what I mentioned].That is <b>data TBL_CAPACITYTAB OCCURS 0</b> is internal table with workarea.I don't find the usuage of TBL_CAPACITYTAB1,TBL_CAPACITYTAB2,TBL_CAPACITYTAB3 anywhere in the program.Why you are using it?

Former Member
0 Kudos

TABLES : AFIH, " MAINTANCE ORDER TABLE

AUFK, " ORDER MASTER TABLE

AFVGD, " Order:Dialog table for Table AFVG(order operation)

CAUFVD, " Dialog structure for order headers and items

AFKO, " Order header data PP orders

AFVV, " DB structure of the quant values in the operation

AFVC, " Operation within an order

AFVU, " DB structure of the user fields of the operation

ILOA, " PM Object Location and Account Assignment

CRHD, " Work Center Header

JEST. " Individual Object Status

*DATA : ZCAPACITYTAB TYPE ZCAPACITYTAB.

*DATA : BEGIN OF TBL_CAPACITYTAB OCCURS 0,

*

  • INCLUDE STRUCTURE ZSTRUCT.

*

  • END OF TBL_CAPACITYTAB.

&----


&

& Internal Tables &

&----


&

DATA: BEGIN OF TBL_CAPACITYTAB OCCURS 0,

ARBPL like CRHD-ARBPL, "Work Centre

AUFNR LIKE AUFK-AUFNR, "SO #

KTEXT LIKE AUFK-KTEXT, "SO Description

VORNR LIKE AFVC-VORNR, "Operation No.

FSAVD LIKE AFVV-FSAVD, "Operation Start

LTXA1 LIKE AFVC-LTXA1, "Operation Description

ANZZL LIKE AFVC-ANZZL, "Staff

DAUNO LIKE AFVV-DAUNO, "Duration

TPLNR LIKE VAFILOA-TPLNR, "Functional Location

USR04 LIKE AFVU-USR04, "Start Km

END OF TBL_CAPACITYTAB.

DATA : FNAM TYPE RS38L_FNAM.

DATA :TBL_CAPACITYTAB1 LIKE TBL_CAPACITYTAB OCCURS 0 WITH HEADER LINE,

TBL_CAPACITYTAB2 LIKE TBL_CAPACITYTAB OCCURS 0 WITH HEADER LINE,

TBL_CAPACITYTAB3 LIKE TBL_CAPACITYTAB OCCURS 0 WITH HEADER LINE.

*DATA : WA_CAPACITYTAB LIKE ZCAPACITYTAB.

&----


&

& Data Definition Include &

&----


&

DATA : CHK1,

DAY_NUM TYPE P,

OBJNR LIKE JEST-OBJNR,

END_DATE LIKE SY-DATUM,

S_DATE LIKE SY-DATUM,

E_DATE LIKE SY-DATUM.

&----


&

& SELECTION SCREEN DESIGN AND SELECTION CRITERIA &

&----


&

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_IWERK LIKE AFIH-IWERK DEFAULT 'N200', "PLANT

P_DATE LIKE SY-DATUM. "SAP CALENDER DAY

SELECT-OPTIONS : S_AUART FOR AUFK-AUART, "Work Order Type

S_ARBPL FOR AFVGD-ARBPL, "operational W.centre

S_TPLNR FOR CAUFVD-TPLNR. "Functional Location

SELECTION-SCREEN END OF BLOCK B1.

&----


&

& AT SELECTION-SCREEN &

&----


&

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

DATUM = P_DATE

IMPORTING

WOTNR = DAY_NUM.

IF DAY_NUM <> 1.

MESSAGE I000(ZICPR).

LEAVE LIST-PROCESSING.

ENDIF.

IF P_DATE < SY-DATUM.

MESSAGE I001(ZICPR).

ENDIF.

&----


&

& START-OF-SELECTION &

&----


&

START-OF-SELECTION.

SET PF-STATUS 'S100'.

END_DATE = P_date + 21.

SELECT AUFK~AUFNR AUFK~KTEXT

AFVV~DAUNO AFVV~FSAVD

AFVU~USR04 AFVC~VORNR AFVC~LTXA1 AFVC~ANZZL

AFIH~IWERK

ILOA~TPLNR

CRHD~ARBPL

INTO CORRESPONDING FIELDS OF TABLE TBL_CAPACITYTAB

FROM AUFK

JOIN AFKO ON AUFK~AUFNR = AFKO~AUFNR

JOIN AFVV ON AFKO~AUFPL = AFVV~AUFPL

JOIN AFVC ON AFKO~AUFPL = AFVC~AUFPL and AFVV~APLZL = AFVC~APLZL

LEFT OUTER JOIN AFVU ON AFVV~AUFPL = AFVU~AUFPL

AND AFVV~APLZL = AFVU~APLZL

JOIN AFIH ON AFKO~AUFNR = AFIH~AUFNR

JOIN ILOA ON AFIH~ILOAN = ILOA~ILOAN

JOIN CRHD ON AFVC~ARBID = CRHD~OBJID AND CRHD~OBJTY = 'A'

WHERE AFVV~FSAVD >= P_date and AFVV~FSAVD <= END_DATE " '000000500400'

AND AFIH~IWERK = P_IWERK

AND AUFK~AUART IN S_AUART

AND CRHD~ARBPL IN S_ARBPL

AND ILOA~TPLNR IN S_TPLNR.

LOOP AT TBL_CAPACITYTAB.

DATA: L_DATE LIKE SY-DATUM.

CONCATENATE 'OR' TBL_CAPACITYTAB-AUFNR INTO OBJNR.

SELECT SINGLE * FROM JEST

WHERE OBJNR = OBJNR

AND STAT NOT IN ('CLSD' , 'TECO' )

AND INACT <> 'X'.

IF SY-SUBRC <> 0.

DELETE TBL_CAPACITYTAB FROM TBL_CAPACITYTAB.

CONTINUE.

ENDIF.

ENDLOOP.

S_DATE = P_DATE.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 1, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

LOOP AT TBL_CAPACITYTAB WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

  • PERFORM PRINT_DATA.

ENDLOOP.

  • ULINE.

**

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

*

SKIP 1.

WRITE:/ ' Week 2, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

  • PERFORM PRINT.

LOOP AT TBL_CAPACITYTAB WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

  • PERFORM PRINT_DATA.

ENDLOOP.

  • ULINE.

***

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 3, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

LOOP AT TBL_CAPACITYTAB WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

  • PERFORM PRINT_DATA.

ENDLOOP.

<u><b>I NEED TO CONNECT THIS REPORT TO SMARTFORM... PLEASE CHECK THE ERRORS INSIDE THE REPORT... I DID NOT DECLARED ZSTRUCT AS STRUCTURE IN MY REPORT..

PLEASE GUIDE ME THE STEPS..

BECAUSE I AM FRESHER.

I DID NOT USE WA_CAPACITYTAB IN MY REPORT.</b></u>

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Whatever you pasted I modified it accordingly.Since I am not able to find the usuage of TBL_CAPACITYTAB1,TBL_CAPACITYTAB2,TBL_CAPACITYTAB3 in the code you pasted I deleted it.If you want to pass itab in my modified code,just create a structure in SE11 which contains the following fields

ARBPL like CRHD-ARBPL, "Work Centre

AUFNR LIKE AUFK-AUFNR, "SO #

KTEXT LIKE AUFK-KTEXT, "SO Description

VORNR LIKE AFVC-VORNR, "Operation No.

FSAVD LIKE AFVV-FSAVD, "Operation Start

LTXA1 LIKE AFVC-LTXA1, "Operation Description

ANZZL LIKE AFVC-ANZZL, "Staff

DAUNO LIKE AFVV-DAUNO, "Duration

TPLNR LIKE VAFILOA-TPLNR, "Functional Location

USR04 LIKE AFVU-USR04

I assume that you named that structure as ZSTRUCT.

Then your program should be...

TABLES : AFIH, " MAINTANCE ORDER TABLE

AUFK, " ORDER MASTER TABLE

AFVGD, " Order:Dialog table for Table AFVG(order operation)

CAUFVD, " Dialog structure for order headers and items

AFKO, " Order header data PP orders

AFVV, " DB structure of the quant values in the operation

AFVC, " Operation within an order

AFVU, " DB structure of the user fields of the operation

ILOA, " PM Object Location and Account Assignment

CRHD, " Work Center Header

JEST. " Individual Object Status

*DATA : ZCAPACITYTAB TYPE ZCAPACITYTAB.

*DATA : BEGIN OF TBL_CAPACITYTAB OCCURS 0,

*

  • INCLUDE STRUCTURE ZSTRUCT.

*

  • END OF TBL_CAPACITYTAB.

&----


&

& Internal Tables &

&----


&

DATA : FNAM TYPE RS38L_FNAM.

data : itab type standard table of ZSTRUCT,

wa type ZSTRUCT,

itab1 type standard table of ZSTRUCT,

wa1 type ZSTRUCT,

itab2 type standard table of ZSTRUCT,

wa2 type ZSTRUCT,

itab3 type standard table of ZSTRUCT,

wa3 type ZSTRUCT,

i_jest type standard table of jest.

&----


&

& Data Definition Include &

&----


&

DATA : CHK1,

DAY_NUM TYPE P,

OBJNR LIKE JEST-OBJNR,

END_DATE LIKE SY-DATUM,

S_DATE LIKE SY-DATUM,

E_DATE LIKE SY-DATUM.

&----


&

& SELECTION SCREEN DESIGN AND SELECTION CRITERIA &

&----


&

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_IWERK LIKE AFIH-IWERK DEFAULT 'N200', "PLANT

P_DATE LIKE SY-DATUM. "SAP CALENDER DAY

SELECT-OPTIONS : S_AUART FOR AUFK-AUART, "Work Order Type

S_ARBPL FOR AFVGD-ARBPL, "operational W.centre

S_TPLNR FOR CAUFVD-TPLNR. "Functional Location

SELECTION-SCREEN END OF BLOCK B1.

&----


&

& AT SELECTION-SCREEN &

&----


&

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

DATUM = P_DATE

IMPORTING

WOTNR = DAY_NUM.

IF DAY_NUM <> 1.

MESSAGE I000(ZICPR).

LEAVE LIST-PROCESSING.

ENDIF.

IF P_DATE < SY-DATUM.

MESSAGE I001(ZICPR).

ENDIF.

&----


&

& START-OF-SELECTION &

&----


&

START-OF-SELECTION.

SET PF-STATUS 'S100'.

END_DATE = P_date + 21.

SELECT AUFK~AUFNR AUFK~KTEXT

AFVV~DAUNO AFVV~FSAVD

AFVU~USR04 AFVC~VORNR AFVC~LTXA1 AFVC~ANZZL

AFIH~IWERK

ILOA~TPLNR

CRHD~ARBPL

INTO CORRESPONDING FIELDS OF TABLE itab

FROM AUFK

JOIN AFKO ON AUFK~AUFNR = AFKO~AUFNR

JOIN AFVV ON AFKO~AUFPL = AFVV~AUFPL

JOIN AFVC ON AFKO~AUFPL = AFVC~AUFPL and AFVV~APLZL = AFVC~APLZL

LEFT OUTER JOIN AFVU ON AFVV~AUFPL = AFVU~AUFPL

AND AFVV~APLZL = AFVU~APLZL

JOIN AFIH ON AFKO~AUFNR = AFIH~AUFNR

JOIN ILOA ON AFIH~ILOAN = ILOA~ILOAN

JOIN CRHD ON AFVC~ARBID = CRHD~OBJID AND CRHD~OBJTY = 'A'

WHERE AFVV~FSAVD >= P_date and AFVV~FSAVD <= END_DATE " '000000500400'

AND AFIH~IWERK = P_IWERK

AND AUFK~AUART IN S_AUART

AND CRHD~ARBPL IN S_ARBPL

AND ILOA~TPLNR IN S_TPLNR.

SELECT * FROM JEST into table i_jest

WHERE STAT NOT IN ('CLSD' , 'TECO' )

AND INACT <> 'X'.

LOOP AT itab into wa.

DATA: L_DATE LIKE SY-DATUM.

CONCATENATE 'OR' wa-AUFNR INTO OBJNR.

read table i_jest into w_jest with key

OBJNR = OBJNR.

IF SY-SUBRC <> 0.

DELETE itab where objnr = wa-objnr.

CONTINUE.

ENDIF.

ENDLOOP.

S_DATE = P_DATE.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 1, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

LOOP AT itab into wa WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

  • PERFORM PRINT_DATA.

ENDLOOP.

  • ULINE.

**

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

*

SKIP 1.

WRITE:/ ' Week 2, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

  • PERFORM PRINT.

LOOP AT itab into wa WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

  • PERFORM PRINT_DATA.

ENDLOOP.

  • ULINE.

***

S_DATE = E_DATE + 1.

E_DATE = S_DATE + 6.

SKIP 1.

WRITE:/ ' Week 3, ' ,' Week Beg : '.

ULINE at 0(sy-linsz) .

LOOP AT into wa WHERE FSAVD GE S_DATE AND

FSAVD LE E_DATE.

  • PERFORM PRINT_DATA.

ENDLOOP.

Former Member
0 Kudos

also tell me how to declare this structure in PRINT PROGRAM.:

<b>DATA : BEGIN OF TBL_CAPACITYTAB OCCURS 0,

INCLUDE STRUCTURE ZCAPACITYTAB.

END OF TBL_CAPACITYTAB.</b>

this declaration is showing error: Unable to interpret structure..pausible causes of error spelling or comma.

Former Member
0 Kudos

Correction :


DATA : BEGIN OF TBL_CAPACITYTAB OCCURS 0,
INCLUDE STRUCTURE ZCAPACITYTAB.
<u>data :</u> END OF TBL_CAPACITYTAB.

Former Member
0 Kudos

hey dude!!

I already replied to it. check out

Santhosh

Former Member
0 Kudos

yeah..i created the same internal table as structure zcapacity.. but still it showing some error message.

In form interface, i given as tbl_capacitytab type zcapacitytab.

in global def.,wa_capacitytab type zcapacitytab.

in tables, data loop-->tblcapacitytab into wa_capacitytab.

THIS DECLARATION IS RIGHT ? or else any further...still i am not getting data to the form.

i passed wa_capacitytab-arbpl,

wa_capacitytab-aufnr,

-


---

is this right or wrong?

Former Member
0 Kudos

form interface

tbl_capacitytab LIKE zcapacitytab

global defintion

wa_capacitytab type zcapacitytab

Have you designed and created the table under the 'MAIN WINDOW'?

If so,

Under loop you have to declare it,

In the ABAP print program

Have you passed the data into tbl_capacitytab ?

You will have a code in the ABAP print program something like this...

  • now call the generated function module

call function fm_name

exporting

  • archive_index =

  • archive_parameters =

  • control_parameters =

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

  • output_options =

  • user_settings = 'X'

  • importing document_output_info =

  • job_output_info =

  • job_output_options =

tables

ITAB = tbl_capacitytab

exceptions formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5.

WHERE ITAB is the internal table into which the data is stored from the query.

check for all these.....

and Get back..

Regards santhosh

Former Member
0 Kudos

Hi,

If I am right, you should declare the interface table as DDIC structure. You should create it using tr.code SE11.

Former Member
0 Kudos

yes. i created the table in the main window itself.

because zcapacitytab is a structure..

in forminterface: tbl_capacitytab <b><u>type</u></b> zcapacitytab. (Here LIKE statement is showing errror)

in global : wa_capacitytab type zcapacitytab

In loop , I declared as tabl_capacitytab INTO wa_capacitytab.

Former Member
0 Kudos

How did you create 'zcapacitytab' in SE11? created a separate domain element or copied the domain, data element for the fields in the structure from the existing table?

Also check where you have declared the following

<b>tbl_capacitytab type zcapacitytab</b> in the form interface

You have to make the table declaration in

form interface -> Tables

tbl_capacitytab <b>like</b> zcapacitytab

What sort of error are you getting?

Regards

Santhosh

Former Member
0 Kudos

i created using <u>datatype</u> in se11.

where should v declare this

<b>tbl_capacitytab type zcapacitytab</b> in the form interface?

I declared in the tables section.

tbl_capacitytab type zcapacitytab1.

in global data: wa_capacitytab type zcapacitytab1.

In loop,

tbl_capacity INTO wa_capacitytab1

Former Member
0 Kudos

HARI,

using data type in <b>SE11</b> -choose structure it will create one for you, then you should go ahead and declare the exact fields one by one within the structure(create a data element.domain for each and every field)that you want to include either by creating a new one or copying from the database table, then you activate the structure.

Now your structure is ready to be used in the form.

Q1 Have you done this ?

Then you declare the structure in the form interface

tbl_capacitytab LIKE zcapacitytab (you have to use LIKE if you have created the structure correctly it should work)

Also check your abap print program that's where the data comes from into the smartform.

using the Debugger mode check whether you have got the data in the itab in the abap print program.

Let me know what error you are getting? Is it from the smartform side or from the abap print program side

Hope it helps.

Santhosh

Former Member
0 Kudos

my structure zcapacitytab is activated without any errors.

i am getting an error " <u>FORM INTERFACE:</u>TYPE ZCAPACITYTAB IS NOT ALLOWED IN THIS CONTEXT.

i declared my structure in my program as:

data : begin of tbl_capacitytab occurs 0,

include structure zcapacitytab.

end of tbl_capacitytab.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Are you passing the internal table from your ABAP Report?

If so,

Form Interface->Tables

itab like zcapacity

Here zcapacity should be the structured created through SE11.

Global Data

wa type zcapacity

Then

inside the main window,create a loop.

LOOP->Data

itab into wa

create text element.

Then activate the smartform.

In Report,you should have coded as below.

data : v_form_name TYPE rs38l_fnam.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZZZ_TEST3'"name of smartform in capital letter

importing

fm_name = v_form_name

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_form_name

TABLES

itab_select = internal_table "internal table you are passing from program

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.

Hope it helps.If so,reward points.If not,get back.

Former Member
0 Kudos

yes .. i am passing internal table from report.

DATA : FNAM TYPE RS38L_FNAM.

<b>i declared in this way by taking fnam.</b>

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZSAM1'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

<b> FM_NAME = FNAM</b>

  • 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.

LOOP AT TBL_CAPACITYTAB.

CALL FUNCTION '/1BCDWB/SF00000027'

  • EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

TBL_CAPACITYTAB = TBL_CAPACITYTAB

  • 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.

ENDLOOP.

<b>'/1BCDWB/SF00000027'</b>How should I pass this name to FM_NAME in SSF_FUNCTION_MODULE_NAME. It is not taking '/1BCDWB/SF00000027' ...SO I TAKEN AS FNAM and declared as FNAM TYPE RS38L_FNAM.

<u><b>Now my form is activated properly., i created new structure zstruct exactly the same fields as TBL_CAPACITYTAB....

I think the problem with the print program</b></u>

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Two things you have to do.

1. Remove the Loop .. Endloop

2. From your first post,I can see TBL_CAPACITYTAB is a internal table with workarea.Instead of that,just declare

data : itab_struct type standard table of zstruct,

wa_struct type zstruct.

and pass itab_struct in that from instead of TBL_CAPACITYTAB.It is because you are getting only internal table there in smartform.Instead of populating data into TBL_CAPACITYTAB ,populate into itab_struct.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZSAM1'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = FNAM

  • 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.

Remove the loop.

CALL FUNCTION <b>FNAM</b>

TABLES

TBL_CAPACITYTAB = itab_struct

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.

Hope this is clear.If not,get back.Don't forget to reward points for useful answers.