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

TABLE CONTROL??

Former Member
0 Likes
564

Hi,

While retrieving datas into the table control if only one record is there then also same data is coming into all the rows.. what should i do??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
539

Hi,

PBO

******

MODULE FILTER.

LOOP AT ITAB WITH CONTROL <TABLE CONTROL NAME>

MODULE MOVE_DATA_TO_TBCL.

ENDLOOP.

MODULE FILTER OUTPUT.

SORT ITAB BY <GIVE ANY ONE FIELD NAME>

DELETE ADJACENT DUPLICATE FROM ITAB COMPARING <GIVE FIELD NAME>

----


***INCLUDE MZPO_MOVE_DATA_TO_TCO01 .

----


&----


*& Module MOVE_DATA_TO_TC OUTPUT

&----


  • text

----


MODULE MOVE_DATA_TO_TBCL OUTPUT.

move-corresponding: itab to <table control name>.

IF USEFULL REWARD

6 REPLIES 6
Read only

Former Member
0 Likes
539

hi,

First ur data would come into internal table no?

So sort that table and use

Delete adjacent duplicates from < internal table >

Read only

Former Member
0 Likes
539

See if u r displaying in the table control means,surely u will use internal table to store the values temporarily..

In PAI u can write this data retrieval using query..

In PBO u want to display this contents of the internal table to table control..

In tht u wnt to use read stmt..like as follows

Read Table IT_DET index TABDET-current_line.

If sy-subrc = 0.

Move-corresponding IT_DET to ZMCARSEM_ME51_01.

Endif.

Reward if useful!!!!!!!!!!!1

Read only

Former Member
0 Likes
539

Hi Shyja,

it means the loop getting executed as many lines of table control.check the loop statemant in PAI of the screen.

LOOP AT it_itab INTO wa_itab WITH CONTROL <table control name>

CURSOR <table control name>-current_line.

MODULE module_name

ENDLOOP.

Hope it will help

Rgds

shibu

Read only

Former Member
0 Likes
539

Hi,

Shyja

Actually wht happening is u r field string is getting clear after inserting it into the internal table so after inserting data into the internal table clear the field string.

then u will not get duplicate entries

PLZZZZZZZ Reward if useful

Dont forgetttt to reward

Read only

Former Member
0 Likes
539

Hi shyja,

This is kiran.G.(working in sap).You better to check the below code which is hilighted in underline.The code that is given below is the recording code.

In those place we have to mention the INTERNAL TABLE WITH FIELD and dont FORGET to give REFRESH STATEMENT at the end of the loop.

EX:

perform bdc_field using 'MAKT-MAKTX'

<u><u> g_itab-maktx</u>. </u>

perform bdc_field using 'MARA-MEINS'

<b><u>g_itab-meins.</u></b>

If u satisfy with my answer plz give me REWARD POINTS.

ALONG WITH THIS I HAVE DEVELOP A CODE FOR U.PLZ COPY THE THAT CODE AND EXECUTE.ALONG WITH THAT I HAVE A ATTACH A FLAT FILE BELOW THE PROGRAM CHECK IT ONCE OK.

HAVE A NICE DAY..

CODE:

REPORT ybdc_upload_mm01 .

----


  • Tables

----


TABLES : mara.

----


  • Global BDCDATA Structure

----


DATA: it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

it_msgtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

----


  • Global Variables

----


DATA: gl_infile TYPE string,

gv_msg TYPE string,

v_update VALUE 'A'.

----


  • Internal Table

*----


DATA: BEGIN OF g_itab OCCURS 0,

matnr(20), "Material Number

mbrsh(20), "Account Group

mtart(20), "Material Type

maktx(20), "Material Description

meins(20), "Base Unit Of Measure

END OF g_itab.

----


  • Selection-screen

----


SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_file LIKE rlgrap-filename,

p_mode.

SELECTION-SCREEN : END OF BLOCK b1.

----


  • Fetch A File

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM fetch_file.

START-OF-SELECTION.

----


  • Fetch Data From XLS File

----


PERFORM fetch_data.

----


  • Fetch Data From XLS File

----


PERFORM place_data.

&----


*& Form fetch_file

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_file .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

IMPORTING

file_name = p_file

.

gl_infile = p_file.

ENDFORM. " fetch_file

&----


*& Form fetch_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_data .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gl_infile

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = g_itab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDFORM. " fetch_data

&----


*& Form place_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM place_data .

LOOP AT g_itab.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MATNR'.

perform bdc_field using 'BDC_OKCODE'

'=AUSW'.

perform bdc_field using 'RMMG1-MATNR'

g_itab-matnr."record-MATNR_001.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'."record-KZSEL_01_002.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

g_itab-maktx. "record-MAKTX_003.

  • perform bdc_field using 'MARA-MEINS'

  • g_itab-meins.record-MEINS_004.

perform bdc_field using 'MARA-MTPOS_MARA'

'NORM'."record-MTPOS_MARA_005.

CALL TRANSACTION 'MM02' USING it_bdcdata MODE p_mode

update v_update

MESSAGES INTO it_msgtab.

LOOP AT it_msgtab.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = sy-msgid

lang = sy-langu

no = sy-msgno

v1 = sy-msgv1

v2 = sy-msgv2

v3 = sy-msgv3

v4 = sy-msgv4

IMPORTING

msg = gv_msg

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

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

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

ENDIF.

IF sy-tabix = 1.

WRITE: / 'Process Log' COLOR 3.

ENDIF.

WRITE:/ gv_msg.

ENDLOOP.

REFRESH it_msgtab.

REFRESH it_bdcdata.

ENDLOOP.

ENDFORM. " place_data

----


  • Start new screen *

----


FORM bdc_dynpro USING program dynpro.

CLEAR it_bdcdata.

it_bdcdata-program = program.

it_bdcdata-dynpro = dynpro.

it_bdcdata-dynbegin = 'X'.

APPEND it_bdcdata.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM bdc_field USING fnam fval.

  • IF FVAL <> NODATA.

CLEAR it_bdcdata.

it_bdcdata-fnam = fnam.

it_bdcdata-fval = fval.

APPEND it_bdcdata.

  • ENDIF.

ENDFORM. "BDC_FIELD

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

FLAT FILE

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

M FERT STEEL KG

M ROH IRON KG

Read only

Former Member
0 Likes
540

Hi,

PBO

******

MODULE FILTER.

LOOP AT ITAB WITH CONTROL <TABLE CONTROL NAME>

MODULE MOVE_DATA_TO_TBCL.

ENDLOOP.

MODULE FILTER OUTPUT.

SORT ITAB BY <GIVE ANY ONE FIELD NAME>

DELETE ADJACENT DUPLICATE FROM ITAB COMPARING <GIVE FIELD NAME>

----


***INCLUDE MZPO_MOVE_DATA_TO_TCO01 .

----


&----


*& Module MOVE_DATA_TO_TC OUTPUT

&----


  • text

----


MODULE MOVE_DATA_TO_TBCL OUTPUT.

move-corresponding: itab to <table control name>.

IF USEFULL REWARD