‎2007 Oct 24 10:58 AM
Hi,
I am doing my module pool programing. I am creating 3 screens. In the first screen i am displaying customer no. If i click the customer number it wil display second screen with sales order. If i click sales order header it will display sales order item details.
I create all the screens and table controls in the module pool. My question is how to write the logic and wher exactly(PBO or PAI) write the code.
Regards
Srinu
‎2007 Oct 24 11:04 AM
Hi sree,
In first screen create a button whose text will be 'sales header'. In the PAI of the same screen check for the ok_code = function code of the button and call the second screen.
In the second screen, create a button 'Item details'. In the PAI of the same screen check for the ok_code = function code of the button and call the third screen with item details.
Let me know in case of any concern.
Thank you.
Do award points if found useful as points are moral boosters.
‎2007 Oct 24 11:04 AM
Hi
in PBO
Refer to this is the code for table control:
&----
*& Include MZ_TABLEO01 *
&----
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MYSTATUS'.
SET TITLEBAR 'TITLE-001'.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module POPULATE_IT OUTPUT
&----
text
----
MODULE populate_it OUTPUT.
IF ok_code NE 'ADD' AND
ok_code NE 'DEL'.
IF flag NE 'X'.
SELECT * FROM ztest_so INTO TABLE it_populate.
flag = 'X'.
ENDIF.
ENDIF.
ENDMODULE. " POPULATE_IT OUTPUT
&----
*& Module set_lines OUTPUT
&----
text
----
MODULE set_lines OUTPUT.
DESCRIBE TABLE it_populate LINES sy-tfill.
so_tbl_ctrl-lines = sy-tfill.
ENDMODULE. " set_lines OUTPUT
&----
*& Module move_values_to_tbl_ctrl OUTPUT
&----
text
----
MODULE move_values_to_tbl_ctrl OUTPUT.
MOVE : it_populate-vbeln TO ztest_so-vbeln,
it_populate-bukrs TO ztest_so-bukrs,
it_populate-kunnr TO ztest_so-kunnr,
it_populate-erdat TO ztest_so-erdat.
ENDMODULE. " move_values_to_tbl_ctrl OUTPUT
&----
*& Module set_select_status OUTPUT
&----
text
----
MODULE set_select_status OUTPUT.
READ TABLE it_selected WITH KEY vbeln = it_populate-vbeln.
IF sy-subrc EQ 0.
line_sel_col = 'X'.
ELSE.
line_sel_col = space.
ENDIF.
ENDMODULE. " set_select_status OUTPUT
&----
*& Module clear_okcode OUTPUT
&----
text
----
module clear_okcode output.
CLEAR OK_CODE.
endmodule. " clear_okcode OUTPUT
and in PAI
&----
*& Include MZ_TABLEI01 *
&----
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
module USER_COMMAND_0100 input.
case ok_code.
when 'BACK' or 'CANC' or 'EXIT'.
leave to screen 0.
when 'SELALL'.
clear IT_selected.
refresh IT_selected.
loop at IT_POPULATE.
move-corresponding IT_POPULATE to IT_selected.
append IT_selected.
endloop.
when 'DESELALL'.
clear IT_selected.
refresh IT_selected.
when 'SAVE'.
LOOP AT IT_SELECTED.
MODIFY ZTEST_SO FROM IT_SELECTED.
ENDLOOP.
LOOP AT IT_DELETED.
DELETE FROM ZTEST_SO WHERE VBELN = IT_DELETED-VBELN.
ENDLOOP.
commit work.
when 'DEL'.
LOOP AT IT_SELECTED.
MOVE-CORRESPONDING IT_SELECTED
TO
IT_DELETED.
APPEND IT_DELETED.
Also delete it from T_SO.
DELETE IT_POPULATE WHERE VBELN = IT_SELECTED-VBELN.
ENDLOOP.
CLEAR IT_SELECTED.
REFRESH IT_SELECTED.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
&----
*& Module get_selected_so INPUT
&----
text
----
module get_selected_so input.
If ok_code ne 'SELALL'.
IF line_sel_col EQ 'X'.
Read table IT_selected with key vbeln = IT_POPULATE-vbeln.
If sy-subrc ne 0.
MOVE-CORRESPONDING ztest_so TO IT_selected.
Append IT_selected.
Else.
MOVE-CORRESPONDING ztest_so TO IT_selected.
Modify IT_selected index sy-tabix.
Endif.
Else.
Read table IT_selected with key vbeln = IT_POPULATE-VBELN.
If sy-subrc eq 0.
Delete IT_selected where VBELN = IT_POPULATE-VBELN.
Endif.
Endif.
ENDIF.
endmodule. " get_selected_so INPUT
‎2007 Oct 24 11:08 AM
hi sree,
check these links, it may be helpful to u.
this link contains information about :
1)Table Controls in ABAP Programs
2)Looping Through an Internal Table
3)Table Controls: Examples with Scrolling
http://help.sap.com/saphelp_47x200/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm
Reward me if useful.......
Harimanjesh AN
‎2007 Oct 24 11:16 AM
Hi,
In case of dialog program concept
consists of....
->top include
declarations are done....
->PBO module (process before output):
can give PF-STATUS
set-title
reset values
->PAI module (process after input)
this is where the function codes are captured and respective operations are performed.....
ex: case ok-code //declare data:ok-code like sy-ucomm.
when 'ENTER' //ENTER is a function code
//do as per required...
endcase.
<b>reward points if useful.</b>
regards,
Vinod Samuel.
‎2007 Oct 24 11:30 AM
hi
good
go through this table control codes
REPORT Y730_BDC5 .
*HANDLING TABLE CONTROL IN BDC
DATA : BEGIN OF IT_DUMMY OCCURS 0,
DUMMY(100) TYPE C,
END OF IT_DUMMY.
DATA : BEGIN OF IT_XK01 OCCURS 0,
LIFNR(10) TYPE C,
BUKRS(4) TYPE C,
EKORG(4) TYPE C,
KTOKK(4) TYPE C,
NAME1(30) TYPE C,
SORTL(10) TYPE C,
LAND1(3) TYPE C,
SPRAS(2) TYPE C,
AKONT(6) TYPE C,
FDGRV(2) TYPE C,
WAERS(3) TYPE C,
END OF IT_XK01,
BEGIN OF IT_BANK OCCURS 0,
BANKS(3) TYPE C,
BANKL(10) TYPE C,
BANKN(10) TYPE C,
KOINH(30) TYPE C,
LIFNR(10) TYPE C,
END OF IT_BANK.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'C:\VENDOR.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = IT_DUMMY.
LOOP AT IT_DUMMY.
IF IT_DUMMY-DUMMY+0(2) = '11'.
IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
APPEND IT_XK01.
ELSE.
IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
APPEND IT_BANK.
ENDIF.
ENDLOOP.
LOOP AT IT_XK01.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-REF_LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
IT_XK01-LIFNR.
perform bdc_field using 'RF02K-BUKRS'
IT_XK01-BUKRS.
perform bdc_field using 'RF02K-EKORG'
IT_XK01-EKORG.
perform bdc_field using 'RF02K-KTOKK'
IT_XK01-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-TELX1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
IT_XK01-NAME1.
perform bdc_field using 'LFA1-SORTL'
IT_XK01-SORTL.
perform bdc_field using 'LFA1-LAND1'
IT_XK01-LAND1.
perform bdc_field using 'LFA1-SPRAS'
IT_XK01-SPRAS.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
DATA : FNAM(20) TYPE C,
IDX TYPE C.
MOVE 1 TO IDX.
LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKS.
CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKL.
CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKN.
CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-KOINH.
IDX = IDX + 1.
ENDLOOP.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFB1-AKONT'
IT_XK01-AKONT.
perform bdc_field using 'LFB1-FDGRV'
IT_XK01-FDGRV.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
IT_XK01-WAERS.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'WYT3-PARVW(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL TRANSACTION 'XK01' USING IT_BDCDATA
MODE 'A'
UPDATE 'S'
MESSAGES INTO IT_BDCMSGCOLL.
ENDLOOP.
FORM BDC_DYNPRO USING PROG SCR.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROG.
IT_BDCDATA-DYNPRO = SCR.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDFORM.
http://hometown.aol.com/skarkada/sap/table_control/table_control.htm
reward point if helpful.
thanks
mrutyun^
‎2007 Oct 24 11:34 AM
Hi
Try like this
process before output.
*&spwizard: pbo flow logic for tablecontrol 'MY_TAB'
module my_tab_change_tc_attr.
*&spwizard: module MY_TAB_change_col_attr.
loop at it_item
into wa_item
with control my_tab
cursor my_tab-current_line.
module my_tab_get_lines.
*&spwizard: module MY_TAB_change_field_attr
endloop.
module status_0100.
module set_curson.
module get_date.
module ok_code.
process after input.
*&spwizard: pai flow logic for tablecontrol 'MY_TAB'
loop at it_item.
chain.
field wa_item-zeile.
field wa_item-matnr.
field wa_item-maktx.
field wa_item-meins.
field wa_item-menge.
field wa_item-rflag.
module my_tab_modify on chain-request.
endchain.
endloop.
module my_tab_user_command.
*&spwizard: module MY_TAB_change_tc_attr.
*&spwizard: module MY_TAB_change_col_attr.
module get_vendor_name.
module user_command_0100.
For second screen
PROCESS BEFORE OUTPUT.
*&spwizard: pbo flow logic for tablecontrol 'CON_TAB'
module CON_TAB_change_tc_attr.
*&spwizard: module CON_TAB_change_col_attr.
loop at IT_DB_ITEM
into WA_DB_ITEM
with control CON_TAB
cursor CON_TAB-current_line.
module CON_TAB_get_lines.
*&spwizard: module CON_TAB_change_field_attr
endloop.
MODULE STATUS_0110.
*
PROCESS AFTER INPUT.
*&spwizard: pai flow logic for tablecontrol 'CON_TAB'
loop at IT_DB_ITEM.
chain.
field WA_DB_ITEM-ZEILE.
field WA_DB_ITEM-MATNR.
field WA_DB_ITEM-MAKTX.
field WA_DB_ITEM-MEINS.
field WA_DB_ITEM-MENGE.
field WA_DB_ITEM-RFLAG.
endchain.
endloop.
module CON_TAB_user_command.
*&spwizard: module CON_TAB_change_tc_attr.
*&spwizard: module CON_TAB_change_col_attr.
MODULE USER_COMMAND_0110.Regards
Pavan