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

CONVERSIONS

Former Member
638

Hi All,

My requairment is i need to select the records from vbak veda table based on some conditions and need display the list of those records from that list user selects some records and he will process the bdc session or calltransaction.by default all the documents will be selected .first selection screen is with document number and auart .after displaying the list we need to do the bdc process .

Please guide me in this..

Thanks&Regards.

Ramu.

4 REPLIES 4
Read only

Former Member
0 Likes
556

Hi,

U can write a report program where in U will be selecting the required fields from those tables and display them with check-box i.e. each row will be having a checkbox, then user may select the required rows.

U can use the event at user command. After user selects the data u can call the bdc or Call transcation. which inturn will upload the data to the transaction.

Hope this helps.......

Read only

Former Member
0 Likes
556

Hi..,,

execute this sample code..

*"Table declarations...................................................

tables:

vbak. " Sales document Header data

*"Selection screen elements............................................

selection-screen begin of block blck with frame .

select-options

s_docno for vbak-vbeln . " Sales documetnt number.

selection-screen end of block blck.

*" Type declarations...................................................

"----


  • Type declaration of the structure to hold sales documet header data *

  • from table VBAK . *

"----


types:

begin of type_s_sales_documentdata,

vbeln type vbak-vbeln, " Sales document number

erdat type vbak-erdat, " Sales document creation date

ernam type vbak-ernam, " Created by.

vbtyp type vbak-vbtyp, " Document category

auart type vbak-auart, " Document type

lifsk type vbak-lifsk, " Delivery block

faksk type vbak-faksk, " Billing block

netwr type vbak-netwr, " Net value of the document

waerk type vbak-waerk, " SD document currency

vkorg type vbak-vkorg, " Sales organization

kunnr type vbak-kunnr, " Sold to party

check type c, " Check box

end of type_s_sales_documentdata.

"----


  • Type declaration of the structure to hold sales documet ITEM data *

  • from table VBAP. *

"----


types:

begin of type_s_itemdata,

vbeln type vbap-vbeln, " Sales document

end of type_s_itemdata.

"----


  • Internal table to hold sales document header data *

"----


data

t_sales_documentdata type standard table

of type_s_sales_documentdata

initial size 0.

"----


  • Internal table to hold sales document item data *

"----


data

t_itemdata type standard table

of type_s_itemdata

initial size 0.

"----


  • Work area to hold sales document header data *

"----


data

wa_sales_documentdata type type_s_sales_documentdata.

"----


  • Work area to hold sales document item data *

"----


data

wa_itemdata type type_s_itemdata.

"----


  • AT SELECTION-SCREEN EVENT *

"----


at selection-screen.

perform read_vbak.

"----


  • END-OF-SELECTION EVENT *

"----


end-of-selection.

perform display_salesdocument.

----


  • After selecting the records

----


at user-command.

case sy-ucomm.

when 'DISP'.

PERFORM GET_SELECTED_RECORDS.

ENDCASE.

&----


*& Form read_vbak

&----


  • This subroutine retrieves the required data from Vbak table. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


form read_vbak .

select vbeln " Sales document number

erdat " Sales document creation date

ernam " Created by

vbtyp " Document category

auart " Document type

lifsk " Delivery block

faksk " Billing block

netwr " Net value of the document

waerk " SD document currency

vkorg " Sales organization

kunnr " Sold to party

from vbak

into table t_sales_documentdata

where vbeln in s_docno.

if sy-subrc ne 0.

message 'No Data found'(001) type 'E'.

endif. " If sy-subrc ne 0.

endform. " Form read_vbak

&----


*& Form display_Salesdocument *

&----


  • This subroutine generates the list with sales document header data *

----


  • There are no interface parameters to be passed to this subroutine. *

----


form display_salesdocument .

SET PF-STATUS 'STATUS'.

loop at t_sales_documentdata into wa_sales_documentdata.

write:

/ sy-vline, wa_sales_documentdata-check as checkbox,

wa_sales_documentdata-vbeln,sy-vline,

wa_sales_documentdata-erdat, 30 sy-vline,

wa_sales_documentdata-ernam, 48 sy-vline,

wa_sales_documentdata-vbtyp, 55 sy-vline,

wa_sales_documentdata-auart, 60 sy-vline,

wa_sales_documentdata-lifsk, 70 sy-vline,

wa_sales_documentdata-faksk, 80 sy-vline,

wa_sales_documentdata-netwr currency

wa_sales_documentdata-waerk, 107 sy-vline,

wa_sales_documentdata-waerk, 116 sy-vline,

wa_sales_documentdata-vkorg, 125 sy-vline,

wa_sales_documentdata-kunnr, 138 sy-vline.

endloop.

uline (138).

clear wa_sales_documentdata.

endform. " Form display_Salesdocument

*----


  • Form to read the user selected records

*----


form GET_SELECTED_RECORDS.

*Declaration of Work variables...

data:

lw_lines type i, " Holds no.of lines in t_spfli

lw_linno type i value 5.

describe table t_sales_documentdata lines lw_lines.

do lw_lines times.

read line lw_linno field value :

wa_sales_documentdata-check into wa_sales_documentdata-check,

wa_sales_documentdata-vbeln into wa_sales_documentdata-vbeln.

if wa_sales_documentdata-check eq 'X'.

wa_itemdata-vbeln = wa_sales_documentdata-vbeln.

append wa_itemdata-vbeln to t_itemdata.

endif.

clear wa_sales_documentdata-check.

enddo. " Do lw_lines times.

endform.

<b>U need to create a pf-status with name 'STATUS', in this with one push button with function code 'DISP'. <i>and when u press this push button the table t_itemdata contains the user selected Order numers .... now u can do bdc with this table.</i>.</b>

reward points if helpful...

sai ramesh

Read only

Former Member
0 Likes
556

Hi here is a sample code for transaction sm30. Please use this if it helps you...

REPORT zrecord02

NO STANDARD PAGE HEADING LINE-SIZE 255.

CONSTANTS: gc_x TYPE c VALUE 'X', "constants for true value

  • gc_land(40) TYPE c VALUE 'Improper land value', "Constants used in error description

  • gc_imp(50) TYPE c VALUE 'Import Code is already present', "Constants used in error description

  • gc_noimp(60) TYPE c VALUE 'Please enter import code and try', "Constants used in error description

  • gc_dup(50) TYPE c VALUE 'Duplicate Error', "Constants used in error description

gc_dynbegin TYPE c VALUE 'X', "constants used in call transaction

gc_mode TYPE c VALUE 'A', "constants used in call transaction

gc_mode1 TYPE c VALUE 'N', "constants used in call transaction

gc_sucess TYPE c VALUE 'S', "constants used in call transaction

gc_flag TYPE c VALUE 'X', "constants used in call transaction

gc_read TYPE dxfields-fileoper VALUE 'R', "Constants used in form file selection.

gc_applic TYPE dxfields-location VALUE 'A', "application server location

gc_presen TYPE dxfields-location VALUE 'P', "Presentation server location

gc_root(01) TYPE c VALUE '/'. "constant used in file selection

DATA: gv_datab TYPE char12, "Varible to hold the data

gv_date TYPE char2,

gv_mon TYPE char2,

gv_year TYPE char4,

gv_no_succs TYPE i,

gv_no_error TYPE i,

gv_msg TYPE char100,

gv_id TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-t01.

PARAMETERS: p_upl_ps RADIOBUTTON GROUP g DEFAULT 'X', "radiobutton for presentation server

p_upl_as RADIOBUTTON GROUP g, "radiobutton for application server

p_file TYPE rlgrap-filename, "file name

p_test AS CHECKBOX. "for testmode

SELECTION-SCREEN END OF BLOCK b.

TYPES: BEGIN OF gs_itab , " structure containing the fields of flat file.

land1 TYPE v_t604-land1,

stawn TYPE v_t604-stawn,

text1 TYPE v_t604-text1,

bemeh TYPE v_t604-bemeh,

impma TYPE v_t604-impma,

minol TYPE v_t604-minol,

END OF gs_itab.

DATA: gi_itab TYPE TABLE OF gs_itab , "internal table for the structure gs_itab

gi_valid_itab TYPE TABLE OF gs_itab, "internal table for the structure gs_itab with valid fields alone.

gi_dup_itab TYPE TABLE OF gs_itab, "internal table for the structure gs_itab to capture the duplicate values

gw_itab TYPE gs_itab, " work area of gs_itab

gw_validitab TYPE gs_itab.

  • gw_finalitab TYPE gs_itab.

TYPES: BEGIN OF gs_e_itab, " structure containing the error fields of flat file.

land1 TYPE v_t604-land1,

stawn TYPE v_t604-stawn,

text1 TYPE v_t604-text1,

bemeh TYPE v_t604-bemeh,

impma TYPE v_t604-impma,

minol TYPE v_t604-minol,

err(30) TYPE c,

END OF gs_e_itab.

DATA: gi_err_itab TYPE TABLE OF gs_e_itab, " internal table for the structure gs_e_itab.

gw_err_itab TYPE gs_e_itab. "work area for the structure gs_itab

  • gw_itab1 TYPE gs_e_itab.

TYPES: BEGIN OF gs_land_stawn, "structure containing land and import codes of flat file.

land1 TYPE t005-land1,

stawn TYPE t604-stawn,

END OF gs_land_stawn.

DATA: gi_land_stawn TYPE TABLE OF gs_land_stawn, " internal table containing valid land and import codes of flat file

gi_err_land_stawn TYPE TABLE OF gs_land_stawn, " internal table containing error land and import codes of flat file

gw_land_stawn TYPE gs_land_stawn. " work area for the above internal table.

TYPES: BEGIN OF gs_land, "structure containing land field alone

land1 TYPE t005-land1,

END OF gs_land.

DATA: gi_land TYPE TABLE OF gs_land, " internal table for the structure gs_land

gi_c_land TYPE TABLE OF gs_land, " gi_b_land, " internal table for the structure gs_land with only valid land fields

gw_land TYPE gs_land. "work area for gs_land

DATA: BEGIN OF gs_temp, "structure containing the fields of legacy file.

line(1000) TYPE c,

END OF gs_temp.

DATA: gi_temp LIKE TABLE OF gs_temp, "internal table for the structure gs_temp,

gw_temp LIKE gs_temp. "work area for gs_temp

DATA: gi_bdcdata TYPE TABLE OF bdcdata, "internal table for bdcdata

gi_msg TYPE TABLE OF bdcmsgcoll. "internal table for bdcmsgcoll

DATA: gw_bdcdata TYPE bdcdata, "workarea for bdcdata

gw_msg TYPE bdcmsgcoll. "workarea for bdcmsgcoll

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

&----


  • AT SELECTION-SCREEN

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM file_selection. "Selecting the file from the server

&----


  • TOP-OF-PAGE

----


TOP-OF-PAGE.

PERFORM gf_header. "Calling the header Section

&----


  • END-OF-PAGE

----


END-OF-PAGE.

EXIT.

&----


  • START-OF-SELECTION

----


START-OF-SELECTION.

PERFORM upload. "Uploading the file to internal table

PERFORM get_data. "Splitting the pipe delimited data

IF p_test = gc_x. "In test mode

PERFORM validations.

PERFORM remove_duplicate.

PERFORM display.

ELSE. "not in test mode

PERFORM validations.

PERFORM remove_duplicate.

PERFORM bdc.

PERFORM display.

ENDIF.

PERFORM no_of_records.

&----


  • END-OF-SELECTION

----


END-OF-SELECTION.

EXIT.

&----


*& Form file_selection.

&----


  • text

----


FORM file_selection.

CONSTANTS: lc_slash(2) TYPE c VALUE '//'.

DATA : lv_file_path TYPE dxfields-longpath,

lv_location TYPE dxfields-location,

lv_server TYPE msxxlist-name,

ls_rfcsi TYPE rfcsi.

CLEAR:lv_server,lv_location, lv_file_path.

MOVE gc_read TO lv_file_path.

IF lv_file_path IS INITIAL.

lv_file_path = gc_root.

ENDIF.

IF NOT p_upl_ps IS INITIAL.

lv_location = gc_presen. "if presentation server is selected

ELSE.

lv_location = gc_applic. "if application server is selected

ENDIF.

CALL FUNCTION 'RFC_SYSTEM_INFO'

IMPORTING

rfcsi_export = ls_rfcsi.

lv_server = ls_rfcsi-rfcdest.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'

EXPORTING

i_location_flag = lv_location

i_server = lv_server

i_path = lv_file_path

  • FILEMASK = '.'

fileoperation = p_upl_ps

IMPORTING

  • O_LOCATION_FLAG =

  • O_SERVER =

o_path = lv_file_path

  • ABEND_FLAG =

EXCEPTIONS

rfc_error = 1

  • ERROR_WITH_GUI = 2

OTHERS = 2

.

IF sy-subrc <> 0.

EXIT.

ELSE.

MOVE lv_file_path TO p_file.

ENDIF.

IF p_file(2) EQ lc_slash.

SHIFT p_file LEFT.

ENDIF.

ENDFORM. " FILE_SELECTION

&----


*& Form upload

&----


  • text

----


FORM upload.

DATA: lv_file TYPE string.

lv_file = p_file.

IF NOT p_upl_ps IS INITIAL. "if presentation server is selected

CLEAR gi_itab.

REFRESH gi_itab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_file

filetype = 'ASC'

has_field_separator = ''

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

dat_mode = 'X'

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = gi_temp

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.

ELSE. "If application server is selected

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT "If the data is available on the UNIX/Appl. server get the data

WITH SMART LINEFEED.

IF sy-subrc <> 0.

EXIT.

ENDIF.

DO.

READ DATASET p_file INTO gw_temp-line. "read file which is opened.

APPEND gw_temp TO gi_temp.

IF sy-subrc NE 0.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET p_file. "close the file.

ENDIF.

ENDFORM. "upload

*

&----


*& Form get_data

&----


  • text

----


FORM get_data.

DATA:lv_id TYPE sy-tabix.

gv_id = 0.

IF gi_temp[] IS INITIAL. "If the uploaded internal table is empty.

WRITE: /5 text-001.

EXIT.

ELSE.

LOOP AT gi_temp INTO gw_temp.

lv_id = sy-tabix.

SPLIT gw_temp-line

AT '|'

INTO gw_itab-land1

gw_itab-stawn

gw_itab-text1 "Splitting the pipe delimited data.

gw_itab-bemeh

gw_itab-impma

gw_itab-minol.

IF gw_itab-land1 IS INITIAL. " If the user fails to enter land key

gw_itab-land1 = 'CA'. " Default land to 'CA'.

ENDIF.

IF gw_itab-stawn IS NOT INITIAL. " If import code is present

APPEND gw_itab TO gi_itab.

ELSE.

APPEND gw_itab TO gi_itab.

CLEAR gw_itab.

READ TABLE gi_itab

INTO gw_itab WITH KEY stawn = space. "Read the internal table with empty import code

IF sy-subrc = 0.

gw_err_itab-land1 = gw_itab-land1.

gw_err_itab-stawn = gw_itab-stawn.

gw_err_itab-text1 = gw_itab-text1.

gw_err_itab-bemeh = gw_itab-bemeh.

gw_err_itab-impma = gw_itab-impma.

gw_err_itab-minol = gw_itab-minol.

gw_err_itab-err = text-032.

APPEND gw_err_itab TO gi_err_itab.

gv_id = gv_id + 1.

DELETE gi_itab INDEX lv_id.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM. "get_data

&----


*& Form gf_header

&----


  • text

----


FORM gf_header.

NEW-LINE. " Dispalay the header section

ULINE.

WRITE:/ text-006.

WRITE:/ text-019.

SKIP 1.

WRITE: AT /1 'PROGRAM NAME:'(022),sy-repid,

'DATE :'(023),sy-datum,

AT 100 'TIME :'(024),sy-timlo.

WRITE: AT /1 'FILENAME:'(025),p_file.

ULINE.

SKIP 1.

WRITE:/ text-008.

WRITE:/ text-009.

WRITE:/ text-010.

WRITE: AT 20 text-011.

WRITE: AT 33 text-012.

WRITE: AT 55 text-013.

WRITE: AT 70 text-014.

WRITE: AT 95 text-015.

WRITE: AT 120 text-016.

ULINE.

NEW-LINE.

NEW-LINE.

ENDFORM. "gf_header

&----


*& Form validations

&----


  • text

----


FORM validations.

DATA: lv_id TYPE sy-tabix.

LOOP AT gi_itab INTO gw_itab.

APPEND gw_itab-land1 TO gi_land. "Land code alone is taken into internal table

ENDLOOP.

LOOP AT gi_itab INTO gw_itab.

gw_land_stawn-land1 = gw_itab-land1. "land along with import code is taken into another internal table

gw_land_stawn-stawn = gw_itab-stawn.

APPEND gw_land_stawn TO gi_land_stawn.

ENDLOOP.

SORT gi_land BY land1.

REFRESH gi_c_land.

SELECT land1

FROM t005

INTO TABLE gi_c_land

FOR ALL ENTRIES IN gi_land

WHERE land1 EQ gi_land-land1.

IF sy-subrc = 0.

LOOP AT gi_itab INTO gw_itab.

READ TABLE gi_c_land "Read table with correct land keys

INTO gw_land

WITH KEY land1 = gw_itab-land1 BINARY SEARCH.

IF sy-subrc = 0.

gw_validitab-land1 = gw_itab-land1.

gw_validitab-stawn = gw_itab-stawn.

gw_validitab-text1 = gw_itab-text1.

gw_validitab-bemeh = gw_itab-bemeh.

gw_validitab-impma = gw_itab-impma.

gw_validitab-minol = gw_itab-minol.

APPEND gw_validitab TO gi_valid_itab. "appending correct values to internal table.

ELSE.

gw_err_itab-land1 = gw_itab-land1.

gw_err_itab-stawn = gw_itab-stawn.

gw_err_itab-text1 = gw_itab-text1.

gw_err_itab-bemeh = gw_itab-bemeh.

gw_err_itab-impma = gw_itab-impma.

gw_err_itab-minol = gw_itab-minol.

gw_err_itab-err = text-033.

APPEND gw_err_itab TO gi_err_itab. "Appending incorrect values.

ENDIF.

ENDLOOP.

ENDIF.

SELECT land1 stawn

FROM t604 "Selecting already present land and import codes from gi_land_stawn

INTO TABLE gi_err_land_stawn

FOR ALL ENTRIES IN gi_land_stawn

WHERE land1 = gi_land_stawn-land1 AND stawn = gi_land_stawn-stawn.

IF sy-subrc <> 0.

EXIT.

ELSE.

LOOP AT gi_valid_itab INTO gw_validitab. " gi_itab_a into gw_validitab.

CLEAR gw_err_itab.

lv_id = sy-tabix.

READ TABLE gi_err_land_stawn

INTO gw_land_stawn "Reading internal table containing error import codes

WITH KEY land1 = gw_validitab-land1

stawn = gw_validitab-stawn.

IF sy-subrc = 0.

gw_err_itab-land1 = gw_validitab-land1.

gw_err_itab-stawn = gw_validitab-stawn.

gw_err_itab-text1 = gw_validitab-text1.

gw_err_itab-bemeh = gw_validitab-bemeh.

gw_err_itab-impma = gw_validitab-impma.

gw_err_itab-minol = gw_validitab-minol.

gw_err_itab-err = text-034.

APPEND gw_err_itab TO gi_err_itab. "Appending error values to error internal table.

DELETE gi_valid_itab INDEX lv_id.

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM. "validations

&----


*& Form remove_duplicate

&----


  • text

----


FORM remove_duplicate.

DATA: lv_id TYPE sy-tabix.

LOOP AT gi_valid_itab INTO gw_itab.

APPEND gw_itab TO gi_dup_itab.

ENDLOOP.

CLEAR gw_itab.

SORT gi_valid_itab BY land1 stawn ASCENDING.

SORT gi_dup_itab BY land1 stawn ASCENDING.

DELETE ADJACENT DUPLICATES FROM gi_valid_itab COMPARING land1 stawn. "deleting duplicates from gi_valid_itab.

LOOP AT gi_valid_itab INTO gw_itab.

lv_id = sy-tabix.

READ TABLE gi_dup_itab

INTO gw_validitab

WITH TABLE KEY land1 = gw_itab-land1 "Reading from the internal table containing duplicate values.

stawn = gw_itab-stawn

text1 = gw_itab-text1

bemeh = gw_itab-bemeh

impma = gw_itab-impma

minol = gw_itab-minol.

IF sy-subrc = 0.

DELETE gi_dup_itab

WHERE land1 = gw_itab-land1

AND stawn = gw_itab-stawn "Deleting the correct values from duplicated internal table.

AND text1 = gw_itab-text1

AND bemeh = gw_itab-bemeh "Now it has only duplicaed values.

AND impma = gw_itab-impma

AND minol = gw_itab-minol.

ENDIF.

ENDLOOP.

LOOP AT gi_dup_itab INTO gw_itab.

gw_err_itab-land1 = gw_itab-land1.

gw_err_itab-stawn = gw_itab-stawn.

gw_err_itab-text1 = gw_itab-text1.

gw_err_itab-bemeh = gw_itab-bemeh.

gw_err_itab-impma = gw_itab-impma.

gw_err_itab-minol = gw_itab-minol.

gw_err_itab-err = text-035.

APPEND gw_err_itab TO gi_err_itab. "Appending the duplicate errors to gi_err_itab

ENDLOOP.

ENDFORM. "remove_duplicate

&----


*& Form no_of_records

&----


  • text

----


FORM no_of_records.

DATA: lv_line TYPE i,

lv_line1 TYPE i,

lv_corr TYPE i,

lv_dup TYPE i,

lv_tot TYPE i,

lv_total TYPE i.

DESCRIBE TABLE gi_itab LINES lv_tot. "Total number of records in the flat file

lv_total = lv_tot + gv_id.

WRITE: /5 text-002, 44 lv_total. "'Total number of Records from flat file:', 44 lv_total.

DESCRIBE TABLE gi_valid_itab LINES lv_line. "Total number of valid records.

WRITE: /5 text-003, 44 lv_line. " 'No of correctly processed records:', 44 lv_line.

DESCRIBE TABLE gi_err_itab LINES lv_line1. "Total number of error records.

WRITE: /5 text-004, 44 lv_line1. "'No of Error Records:', 44 lv_line1.

lv_corr = lv_line + lv_line1. "Total number of duplicate records.

lv_dup = lv_total - lv_corr.

WRITE: /5 text-030, 44 lv_dup. "'Total number of exact duplicates:', 44 lv_dup.

ENDFORM. "validations

&----


*& Form display

&----


  • text

----


FORM display.

IF gi_err_itab[] IS INITIAL. "If error internal table is empty

WRITE: / sy-uline.

WRITE: /5 text-031."'All the datas are successfully uploaded'.

WRITE: / sy-uline.

ELSE.

LOOP AT gi_err_itab INTO gw_err_itab.

WRITE: / gw_err_itab-land1, 21 gw_err_itab-stawn, 34 gw_err_itab-text1,56 gw_err_itab-bemeh, 71 gw_err_itab-impma, 97 gw_err_itab-minol, 121 gw_err_itab-err.

ENDLOOP.

WRITE: / sy-uline.

ENDIF.

ENDFORM. "display

&----


*& Form bdc

&----


  • text

----


FORM bdc.

DATA: lv_tcode(4) TYPE c VALUE 'SM30'.

IF gi_valid_itab[] IS INITIAL. "If correct internal table is empty, exit.

EXIT.

ELSE.

CONSTANTS: lc_slash TYPE c VALUE '/'.

CLEAR: gv_year, gv_mon, gv_date, gi_bdcdata, gv_datab.

REFRESH gi_bdcdata.

MOVE: sy-datum+0(4) TO gv_year, "Todays data.

sy-datum+4(2) TO gv_mon,

sy-datum+6(2) TO gv_date.

CONCATENATE gv_mon lc_slash gv_date lc_slash gv_year INTO gv_datab.

LOOP AT gi_valid_itab INTO gw_itab.

PERFORM bdc_dynpro USING 'SAPMSVMA' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'VIEWNAME'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

PERFORM bdc_field USING 'VIEWNAME'

'V_T604'.

PERFORM bdc_field USING 'VIMDYNFLDS-LTD_DTA_NO'

'X'.

PERFORM bdc_dynpro USING 'SAPL080E' '0020'.

PERFORM bdc_field USING 'BDC_CURSOR'

'V_T604-BEMEH(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=NEWL'.

PERFORM bdc_dynpro USING 'SAPL080E' '0040'.

PERFORM bdc_field USING 'BDC_CURSOR'

'V_T604-MINOL'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UEBE'.

PERFORM bdc_field USING 'V_T604-LAND1'

gw_itab-land1.

PERFORM bdc_field USING 'V_T604-STAWN'

gw_itab-stawn.

PERFORM bdc_field USING 'V_T604-TEXT1'

gw_itab-text1.

PERFORM bdc_field USING 'V_T604-BEMEH'

gw_itab-bemeh.

PERFORM bdc_field USING 'V_T604-IMPMA'

gw_itab-impma.

PERFORM bdc_field USING 'V_T604-MINOL'

gw_itab-minol.

PERFORM bdc_dynpro USING 'SAPL080E' '0020'.

PERFORM bdc_field USING 'BDC_CURSOR'

'V_T604-BEMEH(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BACK'.

PERFORM bdc_dynpro USING 'SAPLSPO1' '0100'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=YES'.

PERFORM bdc_dynpro USING 'SAPLSTRD' '0300'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KO008-TRKORR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=INSA'.

PERFORM bdc_field USING 'KO008-TRKORR'

'BS7K900776'.

PERFORM bdc_dynpro USING 'SAPLSTR8' '0102'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KO013-PROJECT'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=DOUBLECLICK'.

PERFORM bdc_field USING 'KO013-TARSYSTEM'

'BS7.200'.

PERFORM bdc_dynpro USING 'SAPLSTR8' '0102'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KO013-AS4TEXT'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=CREA'.

PERFORM bdc_field USING 'KO013-AS4TEXT'

'another req'.

PERFORM bdc_field USING 'KO013-TARSYSTEM'

'BS7.200'.

PERFORM bdc_dynpro USING 'SAPLSTRD' '0300'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KO008-TRKORR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=LOCK'.

PERFORM bdc_field USING 'KO008-TRKORR'

'BS7K900778'.

PERFORM bdc_dynpro USING 'SAPMSVMA' '0100'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/EBACK'.

PERFORM bdc_field USING 'BDC_CURSOR'

'VIEWNAME'.

PERFORM bdc_transaction USING lv_tcode

.

REFRESH gi_bdcdata.

ENDLOOP.

ENDIF.

ENDFORM. "bdc

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->X_PROGRAM text

  • -->X_DYNPRO text

----


FORM bdc_dynpro USING x_program TYPE any x_dynpro TYPE any. " BDC sturucture

CLEAR gw_bdcdata.

gw_bdcdata-program = x_program.

gw_bdcdata-dynpro = x_dynpro.

gw_bdcdata-dynbegin = gc_dynbegin.

APPEND gw_bdcdata TO gi_bdcdata.

ENDFORM. "bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • -->X_FNAM text

  • -->X_FVAL text

----


FORM bdc_field USING x_fnam TYPE any x_fval TYPE any.

IF NOT x_fval IS INITIAL.

CLEAR gw_bdcdata.

gw_bdcdata-fnam = x_fnam.

gw_bdcdata-fval = x_fval.

APPEND gw_bdcdata TO gi_bdcdata.

ENDIF.

ENDFORM. "BDC_FIELD

&----


*& Form bdc_transaction

&----


  • text

----


  • -->X_TCODE text

----


FORM bdc_transaction USING x_tcode TYPE any. "BDC Transaction

DATA: lv_flag TYPE c.

CALL TRANSACTION x_tcode USING gi_bdcdata

MODE gc_mode

UPDATE gc_mode1

MESSAGES INTO gi_msg.

IF sy-subrc NE 0.

EXIT.

ENDIF.

CLEAR: lv_flag.

LOOP AT gi_msg INTO gw_msg.

IF gw_msg-msgtyp EQ gc_sucess.

IF lv_flag EQ space.

gv_no_succs = gv_no_succs + 1.

lv_flag = gc_flag.

ENDIF.

ELSE.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

msgid = gw_msg-msgid

msgnr = gw_msg-msgnr

msgv1 = gw_msg-msgv1

msgv2 = gw_msg-msgv2

msgv3 = gw_msg-msgv3

msgv4 = gw_msg-msgv4

IMPORTING

message_text_output = gv_msg.

APPEND gv_msg TO gi_msg.

IF lv_flag EQ space.

gv_no_error = gv_no_error + 1.

lv_flag = gc_flag.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. "bdc_transaction

Read only

Former Member
0 Likes
556

Hi,

First you should do recording for BDC using transaction SHDB. It will create a program automatically... in that program you need to create an internal table which contains all the fields to be uploaded into database table through BDC.

Then do the required validations...

The above program may help you..

Regards,

Buvana

Award points if helpful