Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

populate values in table controll

Former Member
0 Likes
632

hi all,

when i am entering some values in table controll,

they are getting displayed but when i save they are not getting saved in database.

can some body give me sample code,

please tell me wht to write in pbo and pai

hi all,

when i am entering some values in table controll,

they are getting displayed but when i save they are not getting saved in database.

can some body give me sample code,

please tell me wht to write in pbo and pai

4 REPLIES 4
Read only

Former Member
0 Likes
587

Hi Ramkumar,

I have The same problem before but i have resolved it now am providing some sample code in which the table control consists of nearly about 40 fields so am saving in my database so kindly check and get back to me if you have any clarifications,

ASE ok_code.

WHEN 'SAVE'.

CLEAR itab[].

LOOP AT ktab INTO wa.

MOVE wa TO itab.

APPEND itab.

ENDLOOP.

SELECT * FROM zmtssr

WHERE usrnm = zusrl-usrnm

AND mont = month

AND yeah = year.

DELETE zmtssr.

ENDSELECT.

LOOP AT ktab INTO wa.

IF wa-day01 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '01' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day01.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day02 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '02' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day02.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day03 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '03' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day03.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day04 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '04' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day04.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day05 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '05' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day05.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day06 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '06' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day06.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day07 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '07' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day07.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day08 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '08' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day08.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day09 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '09' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day09.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day10 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '10' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day10.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day11 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '11' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day11.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day12 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '12' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day12.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day13 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '13' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day13.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day14 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '14' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day14.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day15 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '15' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day15.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day16 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '16' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day16.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day17 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '17' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day17.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day18 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '18' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day18.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day19 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '19' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day19.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day20 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '20' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day20.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day21 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '21' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day21.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day22 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '22' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day22.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day23 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '23' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day23.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day24 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '24' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day24.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day25 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '25' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day25.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day26 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '26' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day26.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day27 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '27' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day27.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day28 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '28' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day28.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day29 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '29' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day29.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day30 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '30' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day30.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

IF wa-day31 NE ' '.

  • CNT = CNT + 1.

CONCATENATE year month '31' INTO datee.

wa1-projt = wa-projt.

wa1-prods = wa-prods.

wa1-clint = wa-clint.

wa1-dat = datee.

wa1-usrnm = zusrl-usrnm.

wa1-mont = month.

wa1-yeah = year.

wa1-day01 = wa-day31.

INSERT into zmtssr values wa1.

CLEAR wa1.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
587

hi ram kumar the following code may help you in solving your problem.the top include ,pbo and pai have been mentioned separately look into it.

&----


& Include ZGR08TOP Module pooL

*& *

&----


PROGRAM ZPROJECTGROUP08.

*defining okcode variables with the same name as used in the screens

*100 and 200.

DATA : OK_CODE1 TYPE SY-UCOMM.

DATA : OK_CODE2 TYPE SY-UCOMM.

DATA : OK_CODEM TYPE SY-UCOMM.

*controls statements for the tabstrip and both the table controls.

CONTROLS TABSTRIPG8 TYPE TABSTRIP.

CONTROLS ZG8TABLECONT TYPE TABLEVIEW USING SCREEN 202.

CONTROLS ZG8TABLECONT2 TYPE TABLEVIEW USING SCREEN 203.

*these declarations are used in the function modules poh and pov used.

DATA : PROGNAME LIKE SY-REPID.

DATA : DYNNUM LIKE SY-DYNNR.

DATA :LINKS TYPE TABLE OF TLINE.

*LIN is used to determine the number of LINS in the internal table

*itabline and lins to determine the number of lines in the internal

*table itabschedule.

DATA: LIN type i value 0.

DATA: LINS TYPE I VALUE 0.

*this variable is used in the quantity check module of screen 203.

DATA: QTY LIKE ZG8_EKET-MENGE,

qtycheck TYPE I VALUE 0.

*these variable is used during the calcu

DATA wa_meins LIKE marm-meinh.

DATA:wa_waers LIKE ZG8_EKPO-WAERS.

*this variable is used in the function module convert_to_local_currency

*during the calculation of the amount in the local currency.

DATA : l_netpr LIKE zG8_ekko-netpr.

*internal table for the tablecontrol ZG8TABLECONT.

data: begin of itabline occurs 0,

ebelp like ZG8_EKPO-EBELP,

matnr like ZG8_EKPO-MATNR,

menge like ZG8_EKPO-MENGE,

maktx like makt-maktx,

p_netpr like ZG8_PRICE-NETPR,

p_waers like ZG8_PRICE-WAERS,

meins like ZG8_PRICE-MEINS,

netpr like zg8_EKPO-NETPR,

waers like zg8_EKkO-WAERS,

MARK1 type c ,

end of itabline.

*internal table created to handle the functionality of transfer of

*marked lines to shedule screen.

DATA : BEGIN OF ITABLINE_del OCCURS 0.

INCLUDE STRUCTURE ZG8_EKPO.

DATA END OF ITABLINE_del.

*internal table for the tablecontrol ZG8TABLECONT2

DATA : BEGIN OF ITABSCHEDULE OCCURS 0,

EBELN LIKE ZG8_EKET-EBELN,

EBELP LIKE ZG8_EKET-EBELP,

ETENR LIKE ZG8_EKET-ETENR,

EINDT LIKE ZG8_EKET-EINDT,

MENGE LIKE ZG8_EKET-MENGE,

MARK2 TYPE c,

END OF ITABSCHEDULE.

*internal table created to handle the functionality of transfer of

*marked lines to shedule screen.

DATA: BEGIN OF ITABSCHEDULE_DEL OCCURS 0.

INCLUDE STRUCTURE ZG8_EKET.

DATA END OF ITABSCHEDULE_DEL.

*tables statements creating required workspaces as well as gaining

*access to dictionary objects

TABLES:ZG8_EKKO,ZG8_EKPO,ZG8_EKET,ZG8_PRICE,T001,LFA1,TCURC,EKKO,marm.

DATA: CHECK TYPE I.

DATA: VAR1 LIKE EKET-EBELP.

DATA: MODAL_PRICE LIKE ZG8_PRICE-NETPR.

DATA: MODAL_UNIT LIKE ZG8_PRICE-MEINS.

DATA: MODAL_CURRENCY LIKE ZG8_PRICE-WAERS.

DATA: row_index TYPE i VALUE 1.

&----


*& Include ZGR08O01 *

&----


&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'SCREEN100'.

set titlebar 'TITLE100'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


module status_0200 output.

IF SY-TCODE EQ 'ZPURCH_GR8' OR SY-TCODE EQ 'ZPURCR_GR8'.

set pf-status 'SCREEN200' EXCLUDING 'PRINT'.

ELSE.

set pf-status 'SCREEN200'.

ENDIF.

set titlebar 'TITLE200'.

  • TABSTRIPG8-ACTIVETAB = 'HEADER'.

endmodule. " STATUS_0200 OUTPUT

&----


*& Module MODIFYSCREEN OUTPUT

&----


  • text

----


*modifying the screen layout according to the transaction called

module modifyscreen output.

case sy-tcode.

when 'ZPURCR_GR8'.

set titlebar 'TITLE1'.

loop at screen.

if screen-name eq 'DISPLAY' or screen-name eq 'MODIFY'.

screen-input = 0.

modify screen.

endif.

endloop.

when 'ZPURDIS_GR8'.

set titlebar 'TITLE2'.

loop at screen.

if screen-name ne 'ZG8_EKKO-EBELN' and screen-name ne 'DISPLAY'.

screen-input = 0.

modify screen.

endif.

endloop.

when 'ZPURCH_GR8'.

loop at screen.

  • To disable the create, display and print pushbutton.

if screen-name = 'CREATE' or screen-name = 'DISPLAY'.

screen-input = 0.

modify screen.

endif.

endloop.

endcase.

endmodule. " MODIFYSCREEN OUTPUT

&----


*& Module INITIALIZATION OUTPUT

&----


  • text

----


*getting the net price from line item and showing it in header details *

module initialization output.

progname = sy-repid.

dynnum = sy-dynnr.

loop at itabline.

if itabline-p_netpr is not initial.

sum.

zg8_ekko-netpr = itabline-NETPR.

endif.

endloop.

endmodule. " INITIALIZATION OUTPUT

&----


*& Module PROCESS202 OUTPUT

&----


  • text

----


module process202 output.

case sy-tcode.

when 'ZPURCR_GR8' or 'ZPURCH_GR8'.

  • Check if the no of line is empty or not.

if lin ne 0.

loop at screen.

  • To make the screen editable.

screen-input = 1.

endloop.

else.

loop at screen.

if screen-name cs 'ITABLINE'.

  • To make the screen non-editable.

screen-input = 0.

modify screen.

endif.

endloop.

endif.

when 'ZPURDIS_GR8'.

loop at screen.

  • To make screen non editable .

screen-input = 0.

modify screen.

endloop.

endcase.

endmodule. " PROCESS202 OUTPUT

&----


*& Module STATUS_0202 OUTPUT

&----


  • text

----


module status_0202 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

describe table itabline lines lin.

zg8tablecont-lines = lin.

*deactivating the push buttons when display transaction is called

if sy-tcode eq 'ZPURDIS_GR8'.

loop at screen.

if screen-group1 = 'GR1'.

screen-active = 0.

modify screen.

endif.

endloop.

endif.

endmodule. " STATUS_0202 OUTPUT

&----


*& Module PROCESS203 OUTPUT

&----


  • text

----


module process203 output.

case sy-tcode.

when 'ZPURCR_GR8' or 'ZPURCH_GR8'.

  • Check if the no of line is empty or not.

if lins ne 0.

loop at screen.

  • To make the screen editable.

screen-input = 1.

endloop.

else.

loop at screen.

if screen-name cs 'ITABSCHEDULE'.

  • To make the screen non-editable.

screen-input = 0.

modify screen.

endif.

endloop.

endif.

when 'ZPURDIS_GR8'.

loop at screen.

  • To make screen non editable .

screen-input = 0.

modify screen.

endloop.

endcase.

endmodule. "process203 OUTPUT

&----


*& Module status_0203 OUTPUT

&----


  • text

----


module status_0203 output.

*Sort the schedule internal table by item number .

sort itabschedule by ebelp.

  • To find out the number of lines in internal table

describe table itabschedule lines lins.

zg8tablecont2-lines = lins.

  • deactivating the push buttons when called in display mode

if sy-tcode eq 'ZPURDIS_GR8'.

loop at screen.

if screen-group1 = 'GR2'.

screen-active = 0.

modify screen.

endif.

endloop.

endif.

endmodule. " status_0203 OUTPUT

&----


*& Module STATUS_0201 OUTPUT

&----


  • text

----


module status_0201 output.

  • SET PF-STATUS '201STATUS'.

  • SET TITLEBAR 'xxx'.

case sy-tcode.

when 'ZPURDIS_GR8'.

loop at screen.

if screen-name cs 'ZG8_EKKO' .

  • To make screen element non editable in display mode.

screen-input = 0.

modify screen.

endif.

endloop.

endcase.

endmodule. " STATUS_0201 OUTPUT

&----


*& Module STATUS_0300 OUTPUT

&----


  • text

----


*MODULE STATUS_0300 OUTPUT.

    • SET PF-STATUS 'xxxxxxxx'.

    • SET TITLEBAR 'xxx'.

  • MODAL_PRICE = ITABLINE-P_NETPR.

  • MODAL_UNIT = ITABLINE-MEINS.

  • MODAL_CURRENCY = ITABLINE-P_WAERS.

  • CLEAR OK_CODEM.

*

*ENDMODULE. " STATUS_0300 OUTPUT

&----


*

*& Include ZGR08I01 *

&----


&----


*& Module okcode1 INPUT

&----


  • text

----


module okcode1 input.

case ok_code1.

when 'CREATE'.

IF NOT zg8_ekko-ebeln CO '0123456789'.

MESSAGE 'PURCHASE ORDER NOT IN THE EXPECTED FORMAT' TYPE 'E'.

ENDIF.

  • checking whether the purchase order number entered exists or not

select single ebeln into zg8_ekko from zg8_ekko where

ebeln = zg8_ekko-ebeln.

if sy-subrc = 0.

message 'the purchase order no: already exists' type 'E'.

else.

leave to screen 200.

endif.

WHEN 'MODIFY' OR 'DISPLAY'.

IF NOT zg8_ekko-ebeln CO '0123456789'.

MESSAGE 'PURCHASE ORDER NOT IN THE EXPECTED FORMAT' TYPE 'E'.

ENDIF.

  • Select data from zekko_grp06 table to header table.

SELECT SINGLE * FROM ZG8_EKKO INTO

CORRESPONDING FIELDS OF ZG8_EKKO WHERE ebeln =

ZG8_EKKO-ebeln.

if sy-subrc = 0.

  • Select data from zekpo_grp06, makt, zprice_grp06 into item table.

SELECT iebelp imatnr imenge mmaktx pnetpr pwaers

imeins inetpr i~waers

FROM ZG8_EKKO AS h JOIN ZG8_EKPO AS i ON

hebeln = iebeln JOIN

makt AS m ON

imatnr = mmatnr JOIN

ZG8_PRICE AS p ON

imatnr = pmatnr

INTO TABLE ITABLINE

WHERE i~ebeln = ZG8_EKKO-ebeln AND

m~spras = 'EN'.

  • Select data from zeket_grp06 into schedule table

SELECT sebelp setenr smenge seindt

FROM ZG8_EKKO AS h

JOIN ZG8_EKPO AS i

ON hebeln = iebeln

JOIN ZG8_EKET AS s

ON iebelp = sebelp AND

hebeln = sebeln

INTO CORRESPONDING FIELDS OF TABLE ITABSCHEDULE

WHERE h~ebeln = ZG8_EKKO-ebeln.

leave to screen 200.

ELSE.

message 'the purchase order DOES NOT exists' type 'E'.

ENDIF.

endcase.

endmodule. " okcode1 INPUT

&----


*& Module exit INPUT

&----


  • text

----


*

*on selecting the cancel button

module exit input.

case ok_code2.

when 'CANCEL'.

data answer type c.

set hold data on.

  • if sy-datar eq 'X'.

call function 'POPUP_TO_CONFIRM'

exporting

text_question = 'Would you like to save the data?'(a02)

importing

answer = answer

exceptions

text_not_found = 1

others = 2.

case answer.

when '1'.

perform save.

when '2'.

message 'SUCCESS: EXITING...SUCCESSFUL' type 'S'.

leave program.

when 'A'.

set screen 200.

endcase.

set hold data off.

  • else.

  • leave program.

  • endif.

*on selecting the exit button

when 'EXIT'.

leave program.

endcase.

endmodule. " exit INPUT

&----


*& Module OKCODE2 INPUT

&----


  • text

----


*

  • validation for company code

module companycode input.

select single bukrs into t001 from t001 where bukrs =

zg8_ekko-bukrs.

if sy-subrc ne 0.

message 'ERROR company code doesnt exist' type 'E'.

endif.

  • ENDIF.

endmodule. " OKCODE2 INPUT

&----


*& Module CURRENCY INPUT

&----


  • text

----


  • validation for currency

module currency input.

select single waers into tcurc from tcurc where waers =

zg8_ekko-waers.

if sy-subrc ne 0.

message 'ERROR CURRENCY doesnt exist' type 'E'.

endif.

  • ENDIF.

endmodule. " CURRENCY INPUT

&----


*& Module VENDOR INPUT

&----


  • text

----


  • validation for vendor

module vendor input.

  • IF OK_CODE2 = 'SAVE'.

select single lifnr into lfa1 from lfa1 where lifnr =

zg8_ekko-llief.

if sy-subrc ne 0.

message 'ERROR VENDOR doesnt exist' type 'E'.

endif.

  • ENDIF.

endmodule. " VENDOR INPUT

&----


*& Module VENDORVALUE INPUT

&----


  • text

----


  • POV for vendor field

module vendorvalue input.

call function 'F4IF_FIELD_VALUE_REQUEST'

exporting

tabname = 'LFA1'

fieldname = 'LIFNR'

  • SEARCHHELP = ' '

  • SHLPPARAM = ' '

dynpprog = progname

dynpnr = dynnum

dynprofield = 'ZG8_EKKO-LLIEF'

  • STEPL = 0

  • VALUE = ' '

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • SUPPRESS_RECORDLIST = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • SELECTION_SCREEN = ' '

  • TABLES

  • RETURN_TAB =

  • EXCEPTIONS

  • FIELD_NOT_FOUND = 1

  • NO_HELP_FOR_FIELD = 2

  • INCONSISTENT_HELP = 3

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

endmodule. " VENDORVALUE INPUT

&----


*& Module CURRENCYVALUE INPUT

&----


  • text

----


  • POV for currency field

module currencyvalue input.

call function 'F4IF_FIELD_VALUE_REQUEST'

exporting

tabname = 'EKKO'

fieldname = 'WAERS'

  • SEARCHHELP = ' '

  • SHLPPARAM = ' '

dynpprog = progname

dynpnr = dynnum

dynprofield = 'ZG8_EKKO-WAERS'

  • STEPL = 0

  • VALUE = ' '

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • SUPPRESS_RECORDLIST = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • SELECTION_SCREEN = ' '

  • TABLES

  • RETURN_TAB =

  • EXCEPTIONS

  • FIELD_NOT_FOUND = 1

  • NO_HELP_FOR_FIELD = 2

  • INCONSISTENT_HELP = 3

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

endmodule. " CURRENCYVALUE INPUT

&----


*& Module PRICEHELP INPUT

&----


  • text

----


  • POH for price field

module pricehelp input.

call function 'HELP_OBJECT_SHOW'

exporting

dokclass = 'TX'

doklangu = sy-langu

dokname = 'ZHELPFORPRICE1'

  • DOKTITLE = ' '

  • CALLED_BY_PROGRAM = ' '

  • CALLED_BY_DYNP = ' '

  • CALLED_FOR_TAB = ' '

  • CALLED_FOR_FIELD = ' '

  • CALLED_FOR_TAB_FLD_BTCH_INPUT = ' '

  • MSG_VAR_1 = ' '

  • MSG_VAR_2 = ' '

  • MSG_VAR_3 = ' '

  • MSG_VAR_4 = ' '

  • CALLED_BY_CUAPROG = ' '

  • CALLED_BY_CUASTAT =

  • SHORT_TEXT = ' '

  • CLASSIC_SAPSCRIPT = ' '

tables

links = links

  • EXCEPTIONS

  • OBJECT_NOT_FOUND = 1

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

endmodule. " PRICEHELP INPUT

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


  • calling the save sub routine

module user_command_0200 input.

case ok_code2.

when 'SAVE'.

perform save.

when 'PRINT'.

SET PARAMETER ID 'GR8' FIELD ZG8_EKKO-EBELN.

call transaction 'ZPOSTSCRIPTGRP8'.

  • perform print.

  • AND SKIP FIRST SCREEN

endcase.

endmodule. " USER_COMMAND_0200 INPUT

&----


*& Module matnr_chk INPUT

&----


  • text

----


module matnr_chk input.

data : m_matnr type mara-matnr,

wa_netpr like zg8_ekpo-netpr.

if ok_code2 <> 'DELETEL'.

select single netpr from zg8_price into wa_netpr

where matnr = itabline-matnr.

if sy-subrc eq 0.

  • To check whether price is maintained for the materail number or not.

if wa_netpr is initial.

message 'Price not maintained for the entered material' type 'E'.

endif.

else.

  • To check whether material number present in zprice_grp06 table .

message 'Material number not maintained in price table ' type 'E'.

endif.

  • fetching the value of material number from itabline table into work

  • area

  • To check whether material number present in MARA` table .

select single matnr into m_matnr from mara

where matnr = itabline-matnr.

if sy-subrc ne 0.

message 'Material Number not maintained in MARA table' type 'E'.

endif.

endif.

endmodule. " matnr_chk INPUT

&----


*& Module ITABLINE_ADD INPUT

&----


  • text

----


module itabline_add input.

if ok_code2 <> 'ADDL' and ok_code2 <> 'DELETEL' and

ok_code2 <> 'SELECTL' and ok_code2 <> 'DESELECTL'.

*Select materail description, price, currency, unit for the material

*number entered

select single m~maktx p~netpr p~waers p~meins

from makt as m join

zg8_price as p

on p~matnr = m~matnr

into

(itabline-maktx, itabline-p_netpr, itabline-p_waers, itabline-meins)

where m~matnr = itabline-matnr

and spras = sy-langu

and p~matnr = itabline-matnr.

  • To transfer currency from header table to item table.

itabline-waers = zg8_ekko-waers.

if itabline-p_netpr is not initial.

  • Call function to convert the currency to header currency .

call function 'CONVERT_TO_LOCAL_CURRENCY'

exporting

  • CLIENT = SY-MANDT

date = sy-datum

foreign_amount = itabline-p_netpr

foreign_currency = zg8_ekko-waers

local_currency = itabline-p_waers

  • RATE = 0

  • TYPE_OF_RATE = 'M'

  • READ_TCURR = 'X'

importing

  • EXMODIFY_RATE =

  • FOREIGN_FACTOR =

local_amount = l_netpr

  • LOCAL_FACTOR =

  • EXMODIFY_RATEX =

  • FIXED_RATE =

  • DERIVED_RATE_TYPE =

exceptions

no_rate_found = 1

overflow = 2

no_factors_found = 3

no_spread_found = 4

derived_2_times = 5

others = 6

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

  • Calculate netprice by multiply quantity and price for each material.

itabline-netpr = itabline-menge * l_netpr.

endif.

  • ENDIF.

  • itabline-netpr = itabline-netpr.

  • To make validation for currency in price table

clear wa_waers.

select single waers from tcurc

into wa_waers

where waers = itabline-p_waers.

if sy-subrc ne 0.

message 'Currency present in price table is not valid' type 'I'.

clear ok_code2.

endif.

  • To make validation for unit in price table

select single meinh from marm into wa_meins

where meinh = itabline-meins.

if sy-subrc ne 0.

message 'Unit present in price table is not valid' type 'I'.

clear ok_code2.

endif.

  • Calling the Modal Dialog Box for users acceptance

  • IF sy-tcode EQ 'ZPURCR_GR8' or sy-tcode EQ 'ZPURCH_GR8'.

  • CALL SCREEN 300 STARTING AT 15 08.

  • ENDIF.

  • ENDIF.

endif.

endmodule. " ITABLINE_ADD INPUT

&----


*& Module modify_line INPUT

&----


  • text

----


module modify_line input.

modify itabline index zg8tablecont-current_line.

endmodule. " modify_line INPUT

&----


*& Module item_gen INPUT

&----


  • text

----


  • generate item number automatically if not entered

module item_gen input.

loop at itabline.

if itabline-ebelp is initial.

itabline-ebelp = sy-tabix.

endif.

modify itabline.

endloop.

endmodule. " item_gen INPUT

&----


*& Module user_command_0202 INPUT

&----


  • text

----


module user_command_0202 input.

data flag type c value '0'.

case ok_code2.

when 'ADDL'.

  • To insert or append an initial line into table control

tabstripg8-activetab = 'LINE'.

loop at itabline.

if itabline-mark1 = 'X'.

insert initial line into itabline.

flag = '1'.

endif.

endloop.

if flag <> '1'.

append initial line to itabline.

endif.

clear ok_code2.

when 'DELETEL'.

  • To delete the seleceted line from table control

loop at itabline.

if itabline-mark1 = 'X'.

move-corresponding itabline to itabline_del.

append itabline_del.

delete itabline.

endif.

endloop.

clear ok_code2.

when 'SELECTL'.

  • To select all the rows of table control

loop at itabline.

itabline-mark1 = 'X'.

modify itabline.

endloop.

when 'DESELECTL'.

  • To deselect the rows of table control

loop at itabline.

itabline-mark1 = ' '.

modify itabline.

endloop.

endcase.

endmodule. " user_command_0202 INPUT

&----


*& Module SCHEDULEITEMS INPUT

&----


  • text

----


module scheduleitems input.

case ok_code2.

when 'header'.

  • Activate TAB_ITEM tabstrip

tabstripg8-activetab = 'header'.

when 'LINE'.

  • Activate TAB_ITEM tabstrip

tabstripg8-activetab = 'LINE'.

when 'SCHEDULE'.

  • Activate TAB_ITEM tabstrip

tabstripg8-activetab = 'SCHEDULE'.

loop at itabline.

clear itabschedule.

if itabline-mark1 = 'X'.

itabschedule-ebelp = itabline-ebelp.

append itabschedule.

itabline-mark1 = ' '.

modify itabline.

endif.

endloop.

loop at itabline_del.

delete itabschedule where ebelp = itabline_del-ebelp.

endloop.

refresh itabline_del.

endcase.

endmodule. " SCHEDULEITEMS INPUT

&----


*& Module MODIFY INPUT

&----


  • text

----


module modify input.

modify itabschedule index zg8tablecont2-current_line.

endmodule. " MODIFY INPUT

&----


*& Module USER_COMMAND_0203 INPUT

&----


  • text

----


module user_command_0203 input.

flag = '0'.

case ok_code2.

when 'ADDS'.

  • To insert or append an initial line into table control

loop at itabschedule.

if itabschedule-mark2 = 'X'.

insert initial line into itabschedule.

flag = '1'.

endif.

endloop.

if flag <> '1'.

append initial line to itabschedule.

endif.

when 'DELETES'.

  • To delete the seleceted line from table control

loop at itabschedule.

if itabschedule-mark2 = 'X'.

move-corresponding itabschedule to itabschedule_del.

append itabschedule_del.

delete itabschedule.

endif.

endloop.

when 'SELECTS'.

  • To select all the rows of table control

loop at itabschedule.

itabschedule-mark2 = 'X'.

modify itabschedule.

endloop.

when 'DESELECTS'.

  • To deselect the rows of table control

loop at itabschedule.

itabschedule-mark2 = ' '.

modify itabschedule.

endloop.

endcase.

endmodule. " USER_COMMAND_0203 INPUT

&----


*& Module SORT INPUT

&----


  • text

----


module sort input.

sort itabschedule by ebelp.

endmodule. " SORT INPUT

&----


*& Module QUANTITYCHECK INPUT

&----


  • text

----


module quantitycheck input.

IF TABSTRIPG8-activetab = 'SCHEDULE' AND

ok_code2 <> 'ADDS' AND ok_code2 <> 'DELETES' AND

ok_code2 <> 'SELECTS' AND ok_code2 <> 'DESELECTS'.

  • LOOP AT ITABLINE.

  • CLEAR ITABSCHEDULE-menge.

  • qty = 0.

  • LOOP AT ITABSCHEDULE WHERE ebelp = ITABLINE-ebelp.

  • qty = qty + ITABSCHEDULE-menge.

  • ENDLOOP.

  • CLEAR ITABSCHEDULE-menge.

  • IF qty <> ITABLINE-menge AND qty <> 0.

  • MESSAGE

  • 'Quantity must be equal to the item quatity ITABLINE-menge '

*TYPE 'I'.

  • CLEAR ok_code2.

*

  • ENDIF.

  • ENDLOOP.

LOOP AT ITABSCHEDULE.

IF ITABSCHEDULE-menge IS INITIAL .

MESSAGE 'Quantity should not be initial' TYPE 'I'.

CLEAR ok_code2.

ENDIF.

ENDLOOP.

ENDIF.

endmodule. " QUANTITYCHECK INPUT

&----


*& Module exit1 INPUT

&----


  • text

----


MODULE exit1 INPUT.

LEAVE PROGRAM.

ENDMODULE. " exit1 INPUT

&----


*& Module DATECHECK INPUT

&----


  • text

----


MODULE DATECHECK INPUT.

IF ITABSCHEDULE-EINDT LT SY-DATUM.

MESSAGE 'DELIVERY DATE IS INVALID' TYPE 'E'.

ENDIF.

ENDMODULE. " DATECHECK INPUT

&----


*& Module USER_COMMAND_0300 INPUT

&----


  • text

----


*MODULE USER_COMMAND_0300 INPUT.

  • IF OK_CODEM = 'OK'.

  • row_index = row_index + 1.

  • SET SCREEN 0.

  • LEAVE SCREEN.

  • ENDIF.

&----


*& Include ZGR08F01 *

&----


&----


*& Form save

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form save .

CHECK = 0.

QTYCHECK = 0.

LOOP AT ITABSCHEDULE.

VAR1 = ITABSCHEDULE-EBELP.

LOOP AT ITABLINE WHERE EBELP = VAR1.

ENDLOOP.

IF SY-SUBRC NE 0.

CHECK = 1.

MESSAGE ' ITEM NOS MISMATCH B/W SCHEDULED AND LINEITEMS ' TYPE 'I'.

EXIT.

ENDIF.

ENDLOOP.

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

LOOP AT ITABLINE.

CLEAR ITABSCHEDULE-menge.

qty = 0.

LOOP AT ITABSCHEDULE WHERE ebelp = ITABLINE-ebelp.

qty = qty + ITABSCHEDULE-menge.

ENDLOOP.

CLEAR ITABSCHEDULE-menge.

IF qty <> ITABLINE-menge AND qty <> 0.

QTYCHECK = 1.

MESSAGE

'Quantity must be equal to the item quatity ITABLINE-menge '

TYPE 'I'.

CLEAR ok_code2.

ENDIF.

ENDLOOP.

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

IF QTYCHECK NE 1.

IF CHECK NE 1 .

IF ZG8TABLECONT-LINES NE 0 AND ZG8TABLECONT2-LINES NE 0.

*Update the entries into header table

modify zg8_ekko.

loop at itabline.

zg8_ekpo-ebeln = zg8_ekko-ebeln.

zg8_ekpo-ebelp = itabline-ebelp.

zg8_ekpo-matnr = itabline-matnr.

zg8_ekpo-menge = itabline-menge.

zg8_ekpo-meins = itabline-meins.

zg8_ekpo-netpr = itabline-netpr.

zg8_ekpo-waers = itabline-waers.

*Update the entries into item table

modify zg8_ekpo.

endloop.

loop at itabschedule.

zg8_eket-ebeln = zg8_ekko-ebeln.

zg8_eket-ebelp = itabschedule-ebelp.

zg8_eket-etenr = itabschedule-etenr.

zg8_eket-menge = itabschedule-menge.

zg8_eket-eindt = itabschedule-eindt.

*update the entries into schedule table

modify zg8_eket.

endloop.

loop at itabline_del.

zg8_ekpo-ebeln = zg8_ekko-ebeln.

zg8_ekpo-ebelp = itabline_del-ebelp.

zg8_ekpo-matnr = itabline_del-matnr.

zg8_ekpo-menge = itabline_del-menge.

zg8_ekpo-meins = itabline_del-meins.

zg8_ekpo-netpr = itabline_del-netpr.

zg8_ekpo-waers = itabline_del-waers.

*Delete the entries into schedule table

delete zg8_ekpo.

message 'hi' type 'i'.

endloop.

loop at itabschedule_DEL.

zg8_eket-ebeln = zg8_ekko-ebeln.

zg8_eket-ebelp = itabschedule_DEL-ebelp.

zg8_eket-etenr = itabschedule_DEL-etenr.

zg8_eket-menge = itabschedule_DEL-menge.

zg8_eket-eindt = itabschedule_DEL-eindt.

*Delete the entries into schedule table

delete zg8_eket.

endloop.

message 'ENTERED DETAILS HAVE BEEN SAVED SUCCESSFULLY' type 'S'.

clear zg8_ekko.

clear itabline. refresh itabline.

clear itabschedule. refresh itabschedule.

tabstripg8-activetab = 'HEADER'.

leave to screen 100.

ELSE.

MESSAGE 'PLEASE FILL THE COMPLETE DETAILS' TYPE 'I'.

ENDIF.

ENDIF.

ENDIF.

endform. " save

*selection-screen begin of screen 400.

*selection-screen begin of block b1.

*select-options S_EBELN for ZG8_EKKO-EBELN.

*selection-screen end of block b1.

*selection-screen end of screen 400.

&----


*& Form print

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


*

*

*form print.

*

*data: begin of ITAB occurs 10,

  • MATNR like ZG8_EKPO-MATNR,

  • MENGE like ZG8_EKPO-MENGE,

  • MEINS like ZG8_EKPO-MEINS,

  • NETPR like ZG8_EKPO-NETPR,

  • WAERS like ZG8_EKPO-WAERS,

  • end of ITAB.

*

*DATA: TOTAL LIKE ZG8_EKPO-NETPR.

*

**select EBELN from ZG8_EKKO where EBELN EQ ZG8_EKKO-ebeln.

*

*

*select * from ZG8_EKPO into corresponding fields of table ITAB

  • where EBELN

  • EQ ZG8_EKKO-ebeln.

*

*SELECT SUM( NETPR ) FROM ZG8_EKPO INTO TOTAL WHERE EBELN

  • EQ ZG8_EKKO-ebeln.

*

*CALL FUNCTION 'OPEN_FORM'

  • EXPORTING

  • FORM = 'ZGR8POSTSCRIPT'.

*

*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 'WRITE_FORM'

  • EXPORTING

  • ELEMENT = 'HEADER DETAILS'

  • WINDOW = 'MAIN'.

*

*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 ITAB.

*CALL FUNCTION 'WRITE_FORM'

  • EXPORTING

  • ELEMENT = 'ITEM DETAILS'

  • WINDOW = 'MAIN'.

*

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

*

*

*

*CALL FUNCTION 'CLOSE_FORM'.

*

*IF SY-SUBRC <> 0.

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

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

*ENDIF. .

*

please reward if found useful.

Read only

Former Member
0 Likes
587

PROGRAM ZTEST_TBLCTRL.

***&SPWIZARD: DATA DECLARATION FOR TABLECONTROL 'TC1'

*&SPWIZARD: DEFINITION OF DDIC-TABLE

TABLES: ZFG_SRNO, ZFIH0004.

*&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'TC1'

*TYPES: BEGIN OF T_TC1,

  • ZSRNO LIKE ZFG_SRNO-ZSRNO,

    • SCRNAME LIKE ZFIH0004-SCRNAME,

  • END OF T_TC1.

*TYPES: BEGIN OF T_TC1.

  • STRUCTURE ZFG_SRNO.

  • END OF T_TC1.

*&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'TC1'

*DATA: G_TC1_ITAB TYPE T_TC1 OCCURS 0 WITH HEADER LINE,

  • G_TC1_WA TYPE T_TC1. "work area

DATA: G_TC1_ITAB LIKE ZFG_SRNO OCCURS 0 WITH HEADER LINE,

G_TC1_WA LIKE G_TC1_ITAB. "work area

DATA: G_TC1_COPIED. "copy flag

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC1' ITSELF

CONTROLS: TC1 TYPE TABLEVIEW USING SCREEN 0100.

*&SPWIZARD: LINES OF TABLECONTROL 'TC1'

DATA: G_TC1_LINES LIKE SY-LOOPC.

DATA: OK_CODE LIKE SY-UCOMM,

S_CODE LIKE SY-UCOMM,

MARK.

DATA: T1(10).

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: COPY DDIC-TABLE TO ITAB

MODULE TC1_INIT OUTPUT.

  • IF G_TC1_COPIED IS INITIAL.

*&SPWIZARD: COPY DDIC-TABLE 'ZFG_SRNO'

*&SPWIZARD: INTO INTERNAL TABLE 'g_TC1_itab'

  • SELECT * FROM ZFG_SRNO

  • INTO CORRESPONDING FIELDS

  • OF TABLE G_TC1_ITAB.

  • G_TC1_COPIED = 'X'.

  • REFRESH CONTROL 'TC1' FROM SCREEN '0100'.

IF T1 <> SPACE.

G_TC1_ITAB-ZSRNO = T1.

CLEAR T1.

APPEND G_TC1_ITAB.

REFRESH CONTROL 'TC1' FROM SCREEN '0100'.

ENDIF.

*TC1-TOP_LINE = 1.

  • ENDIF.

ENDMODULE.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: MOVE ITAB TO DYNPRO

MODULE TC1_MOVE OUTPUT.

MOVE-CORRESPONDING G_TC1_WA TO ZFG_SRNO.

  • if sy-subrc ne 0.

*append G_TC1_WA to G_TC1_ITAB.

*endif.

  • READ TABLE G_TC1_ITAB INDEX TC1-CURRENT_LINE.

  • IF SY-SUBRC = 0.

  • G_TC1_WA-ZSRNO = G_TC1_ITAB-ZSRNO.

  • ENDIF.

  • MOVE-CORRESPONDING G_TC1_ITAB TO ZFG_SRNO.

  • REFRESH CONTROL 'TC1' FROM SCREEN '8001'.

tc1-lines = G_TC1_LINES + 100.

ENDMODULE.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: GET LINES OF TABLECONTROL

MODULE TC1_GET_LINES OUTPUT.

G_TC1_LINES = SY-LOOPC.

ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: MODIFY TABLE

MODULE TC1_MODIFY INPUT.

*break-point.

  • MOVE-CORRESPONDING ZFG_SRNO TO G_TC1_ITAB.

  • MODIFY G_TC1_ITAB INDEX TC1-CURRENT_LINE.

  • G_TC1_COPIED = 'X'.

  • REFRESH CONTROL 'TC1' FROM SCREEN '8001'.

MOVE-CORRESPONDING ZFG_SRNO TO G_TC1_WA.

MODIFY G_TC1_ITAB

FROM G_TC1_WA

INDEX TC1-CURRENT_LINE.

G_TC1_COPIED = 'X'.

if sy-subrc ne 0.

append G_TC1_WA to G_TC1_ITAB.

endif.

*modify G_TC1_ITAB INDEX TC1-CURRENT_LINE.

ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: PROCESS USER COMMAND

MODULE TC1_USER_COMMAND INPUT.

OK_CODE = SY-UCOMM.

PERFORM USER_OK_TC USING 'TC1'

'G_TC1_ITAB'

'FLAG'

CHANGING OK_CODE.

SY-UCOMM = OK_CODE.

ENDMODULE.

&----


*& Module D20XX_INIT OUTPUT

&----


  • text

----


MODULE D20XX_INIT OUTPUT.

*if screen-name = 'ZSRNO'.

  • SCREEN-INPUT = 0.

  • SCREEN-COLOR = 0.

  • MODIFY SCREEN.

  • endif.

ENDMODULE. " D20XX_INIT OUTPUT

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

*CLEAR R1_REF.

  • DO 30 TIMES.

  • APPEND G_TC1_ITAB.

  • ENDDO.

DESCRIBE TABLE G_TC1_ITAB LINES TC1-LINES.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module TAB1_INIT OUTPUT

&----


  • text

----


MODULE TAB1_INIT OUTPUT.

ENDMODULE. " TAB1_INIT OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module MESSAGE INPUT

&----


  • text

----


MODULE MESSAGE INPUT.

OK_CODE = SY-UCOMM.

S_CODE = OK_CODE.

CLEAR OK_CODE.

if S_CODE = 'DELE'.

loop at G_TC1_ITAB.

  • if G_TC1_ITAB-scrname = 'X'.

  • delete g_tc1_itab.

  • endif.

endloop.

ELSEIF S_CODE = 'SAVE'.

G_TC1_WA-ZSRNO = T1.

MOVE-CORRESPONDING G_TC1_WA TO ZFG_SRNO.

****Here you have to write the insert statement to store into database

REFRESH CONTROL 'TC1' FROM SCREEN '0100'.

ENDIF.

ENDMODULE. " MESSAGE INPUT

&----


*& Module DELETE_RECORD INPUT

&----


  • text

----


MODULE DELETE_RECORD INPUT.

IF MARK = 'X' AND S_CODE = 'DELE'.

DELETE TABLE G_TC1_ITAB FROM ZFG_SRNO.

DESCRIBE TABLE G_TC1_ITAB LINES TC1-LINES.

ENDIF.

ENDMODULE. " DELETE_RECORD INPUT

*********************Screen modules*********************

PROCESS BEFORE OUTPUT.

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TC1'

MODULE TC1_INIT.

*&SPWIZARD: MODULE TC1_CHANGE_TC_ATTR.

*&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.

LOOP AT G_TC1_ITAB

INTO G_TC1_WA

WITH CONTROL TC1

CURSOR TC1-CURRENT_LINE.

*&SPWIZARD: MODULE TC1_CHANGE_FIELD_ATTR

MODULE TC1_MOVE.

  • MODULE TAB1_INIT.

  • MODULE TC1_GET_LINES.

ENDLOOP.

MODULE D20XX_INIT.

MODULE STATUS_0100.

*

PROCESS AFTER INPUT.

*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC1'

*BREAK POINT.

LOOP AT G_TC1_ITAB.

CHAIN.

FIELD ZFG_SRNO-ZSRNO.

MODULE TC1_MODIFY ON CHAIN-REQUEST.

  • MODULE TC1_MODIFY.

ENDCHAIN.

MODULE MESSAGE .

MODULE DELETE_RECORD.

ENDLOOP.

MODULE TC1_USER_COMMAND.

*&SPWIZARD: MODULE TC1_CHANGE_TC_ATTR.

*&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.

MODULE USER_COMMAND_0100.

Read only

jayanthi_jayaraman
Active Contributor