‎2006 Feb 01 12:33 PM
Dear All,
I have some questions in Module pool and BDC.
1. how to handle Table Control in module pool programming as it's displaying lines in a table control differs from one system to other.
2. How to handle the same situation while uploading the data in table control in BDC.
Kindly let me know.
Many Thanks,
Ranjan
‎2006 Feb 01 1:10 PM
Hi,
For getting knowledge on how to handle table control,refer this link.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table control in abap.pdf
For getting information on BDC with tablecontrol,refer this link.
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Kindly reward points by clicking the star on the left of reply,if it helps.
‎2006 Feb 01 12:35 PM
Hello Ranjan,
Table Controls are not supported in BDC. If you are dealing with a specific transaction, look for notes with the keywords: [Transaction] Batch Input Table Control
In some cases, SAP offers an alternative transaction or means of input (maybe by BAPI) to allow you to enter the data.
Martin
‎2006 Feb 01 12:37 PM
When you are using CALL TRANSACTION use option OPTIONS-DEFSIZE = 'X'. This will always call up the window in default size whatever the screen resolution be. SAP is making use of this in the recording transaction(SHDB).
‎2006 Feb 01 12:54 PM
Hi Ranjan
The numeber of lines of table control for BDC depend on screen resolution, but It can't be managed by program.
So the better solution is to create a bdc doesn't depend on resolution.
It can do that using always the first two lines of table control.
When you start the simulation, first record has to be placed in first line of tc and the second in second one.
Before placing the third record, it needs to place the second record to the top and so the third record can be placed in the second line.
Before placing the next record, it needs to place the third record to the top and so the fourth record can be placed in the second line and so.
In this way your BDC'll use alwways the first two lines of tc and your program won't depend on resolution.
The problem is the transaction you need to simulate by BDC has to have a scroll functionality to allow to place the last record was elaborated to the top of tc, so the second line of tc can always be used to place the new record.
If there isn't this functionality, it's better to use a BAPI instead of BDC.
Max
‎2006 Feb 01 1:00 PM
Check if this code helps while handling the BDC for table control
-
data for controlling paging on screen 0102
DATA: W_MAXLINES(2) TYPE N,
W_NEXT_LINE(3) TYPE N,
W_PAGE(1), "y = page forward, n otherwise
W_SCRLEN(2) TYPE I,
W_SCRLINE(2) TYPE I.
DATA: BEGIN OF W_HDR.
INCLUDE STRUCTURE D020S.
DATA: END OF W_HDR.
DATA: BEGIN OF W_FLD OCCURS 100.
INCLUDE STRUCTURE D021S.
DATA: END OF W_FLD.
DATA: BEGIN OF W_LOG OCCURS 20.
INCLUDE STRUCTURE D022S.
DATA: END OF W_LOG.
DATA: BEGIN OF W_MC OCCURS 20.
INCLUDE STRUCTURE D023S.
DATA: END OF W_MC.
DATA: BEGIN OF W_DYNPRONAME,
PROGRAM(8) VALUE 'SAPMM60X',
DYNPRO(4) VALUE '0102',
END OF W_DYNPRONAME.
FORM GET_MAX_LINES.
set w_maxlines to the number of var-loop occurrences on the screen so
that we know when to page forward on screen 0102
also initialise w_next_line to zero for GET_NEXT_LINE
this subroutine caters for all cases - including screens without loops
CLEAR: W_MAXLINES,
W_NEXT_LINE.
IMPORT DYNPRO W_HDR
W_FLD
W_LOG
W_MC
ID W_DYNPRONAME.
LOOP AT W_FLD WHERE LTYP EQ 'L'.
MOVE W_FLD-LINE TO W_SCRLINE. "first var-loop line
MOVE W_FLD-LBLK TO W_SCRLEN. "depth of loop block
EXIT.
ENDLOOP.
IF SY-SUBRC EQ 0
AND W_SCRLEN NE 0.
sy-srows = total no of lines on screen
w_scrline = actual first line of loop so that
w_scrline - 1 = number of heading lines (before loop)
4 = no of lines at top of screen - command line, pushbuttons, 2 ulines
3 = no of lines after loop - uline & Page count
w_scrlen = no of lines in loop block
w_maxlines = sy-srows - ( wscrline - 1 ) - 4 - 3
and then 1 less but not sure why!
W_MAXLINES = SY-SROWS - W_SCRLINE - 1 - 4 - 3.
W_MAXLINES = W_MAXLINES - 1.
W_MAXLINES = W_MAXLINES DIV W_SCRLEN.
ELSE.
MOVE 99 TO W_MAXLINES. "this required if no screen loop
ENDIF.
ENDFORM.
FORM GET_NEXT_LINE.
set w_page if page forward is required
W_NEXT_LINE = W_NEXT_LINE + 1.
IF W_NEXT_LINE GT W_MAXLINES.
W_NEXT_LINE = 1.
W_PAGE = 'Y'.
ELSE.
W_PAGE = 'N'.
ENDIF.
ENDFORM.
-
‎2006 Feb 01 1:10 PM
Hi,
For getting knowledge on how to handle table control,refer this link.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table control in abap.pdf
For getting information on BDC with tablecontrol,refer this link.
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Kindly reward points by clicking the star on the left of reply,if it helps.
‎2006 Feb 01 1:51 PM
Hi Jayanthi,
Thanks for your email, but the link that sent is not working, will you please send the link again?
Thanks,
Ranjan
‎2006 Feb 01 1:57 PM
Hi,
Try this and kindly reward points by clicking the star on the left of reply,if it helps.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap-co... control in abap.pdf
‎2006 Feb 01 2:04 PM
‎2006 Feb 01 2:08 PM
Hi,
It's opening for me.It is available in SDN download Technical Samples ABAP library.
Here is the code.
In the flow logic of the screen 9000, write the following code.
PROCESS BEFORE OUTPUT.
MODULE set_status.
MODULE get_t_ctrl_lines.
LOOP AT i_makt WITH CONTROL t_ctrl CURSOR t_ctrl-current_line.
* Dynamic screen modifications
MODULE set_screen_fields.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT i_makt.
FIELD i_makt-pick MODULE check.
FIELD i_makt-zmatnr MODULE zmatnr .
ENDLOOP.
MODULE user_command_9000.
In the program, write the following code.
PROGRAM SAPMZTC MESSAGE-ID zz.
***********************************************************************
* Tables Declaration
***********************************************************************
TABLES: zzz_makt.
***********************************************************************
* Internal table Declaration
***********************************************************************
DATA : i_makt TYPE STANDARD TABLE OF zzz_makt WITH HEADER LINE.
***********************************************************************
* Table control Declaration
***********************************************************************
CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9000'.
***********************************************************************
* Variable Declaration
***********************************************************************
DATA : flg, "Flag to set the change mode
ln TYPE i. "No. of records
*&---------------------------------------------------------------------*
*& Module get_T_CTRL_lines OUTPUT
*&---------------------------------------------------------------------*
* Populating data
*----------------------------------------------------------------------*
MODULE get_t_ctrl_lines OUTPUT.
SELECT zmatnr zmaktx
INTO CORRESPONDING FIELDS OF TABLE i_makt
FROM zzz_makt.
DESCRIBE TABLE i_makt LINES ln.
* To make the vertical scroll bar to come on runtime
t_ctrl-lines = ln + 100.
ENDMODULE. " get_T_CTRL_lines OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* Triggering event according to the user command
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
DATA :lv_fcode LIKE sy-ucomm, "Function Code
lv_answer(1) type c. "Storing the answer
lv_fcode = sy-ucomm.
CASE lv_fcode.
WHEN 'CHANGE'.
* Setting the flag to make the table control in editable mode[excluding
* primary key].
flg = 'Y'.
WHEN 'DELETE'.
* Setting the flag to make the table control in editable mode after
* deleting the selected line
flg = 'Y'.
* Confirmation of delete
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Confirm'
text_question = 'Are you sure to delete from database?'
TEXT_BUTTON_1 = 'Yes'(001)
TEXT_BUTTON_2 = 'No'(002)
IMPORTING
ANSWER = lv_answer.
if lv_answer eq '1'.
* Updating the database table from the internal table
UPDATE zzz_makt FROM TABLE i_makt.
* Deleting the selected row from the internal table
DELETE i_makt WHERE pick = 'X'.
* Deleting the selected row from the database table
DELETE FROM zzz_makt WHERE pick = 'X'.
MESSAGE s005 WITH 'Deleted Successfully'.
ENDIF.
WHEN 'SAVE'.
* Inserting new record or updating existing record in database table
* from the internal table
MODIFY zzz_makt FROM TABLE i_makt.
MESSAGE s005 WITH 'Saved Successfully'.
WHEN 'BACK'.
SET SCREEN '0'.
WHEN 'EXIT' OR 'CANCEL'.
* Leaving the program
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
*& Module set_screen_fields OUTPUT
*&---------------------------------------------------------------------*
* Setting the screen fields
*----------------------------------------------------------------------*
MODULE set_screen_fields OUTPUT.
LOOP AT SCREEN.
IF flg IS INITIAL.
screen-input = 0.
ELSEIF ( flg EQ 'Y' ).
IF ( ( screen-name = 'I_MAKT-ZMAKTX'
OR screen-name = 'I_MAKT-CHECK1' )
AND t_ctrl-current_line LE ln ) .
* Making the screen fields as editable
screen-input = 1.
ELSEIF ( ( screen-name = 'I_MAKT-ZMATNR' )
AND t_ctrl-current_line LE ln ).
* Making the screen field as uneditable
screen-input = 0.
ENDIF.
ENDIF.
* Modifying the screen after making changes
MODIFY SCREEN.
ENDLOOP.
ENDMODULE. " set_screen_fields OUTPUT
*&---------------------------------------------------------------------*
*& Module zmatnr INPUT
*&---------------------------------------------------------------------*
* Appending records to the internal table
*----------------------------------------------------------------------*
MODULE zmatnr INPUT.
MODIFY i_makt INDEX t_ctrl-current_line.
IF t_ctrl-current_line GT ln.
READ TABLE i_makt WITH KEY zmatnr = i_makt-zmatnr.
IF sy-subrc NE 0.
* Inserting record if it does not exist in database
APPEND i_makt.
ELSE.
MESSAGE i005 WITH 'Material Number' i_makt-zmatnr 'already exists'.
ENDIF.
ENDIF.
ENDMODULE. " zmatnr INPUT
*&---------------------------------------------------------------------*
*& Module set_status OUTPUT
*&---------------------------------------------------------------------*
* Setting the GUI status
*----------------------------------------------------------------------*
MODULE set_status OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'ZTITLE'.
ENDMODULE. " set_status OUTPUT
*&---------------------------------------------------------------------
*& Module CHECK INPUT
*&---------------------------------------------------------------------
* Modify the internal table using the current line in table control
*----------------------------------------------------------------------
MODULE check INPUT.
MODIFY i_makt INDEX t_ctrl-current_line.
ENDMODULE. " CHECK INPUT