08-21-2007 2:29 PM
08-21-2007 2:35 PM
Hi,
Send me your requirement because without it i can not understand that which screen i will used in future for recording. Send your functional requirment i will help u. And if possible tell test data.
Ok
Regards
Gurprit Bhatia
08-21-2007 2:41 PM
Hi Raj,
This is a sample both BDC & Call Transaction program for TCode XD01. Choose the radio button while executing which you want to run
Give any Text File in your Presentation Layer with the fields given in the internal table "itab".
&----
*& Report ZA1CTBI
*&
&----
*&
*&
&----
REPORT za1ctbi.
TYPES: BEGIN OF ty_cust,
ktokd TYPE kna1-ktokd,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
sortl TYPE kna1-sortl,
ort01 TYPE kna1-ort01,
land1 TYPE kna1-land1,
spras TYPE kna1-spras,
pstlz TYPE kna1-pstlz,
lzone TYPE kna1-lzone,
END OF ty_cust.
DATA: itab TYPE TABLE OF ty_cust,
wa LIKE LINE OF itab,
bdctab TYPE TABLE OF bdcdata,
wa1 LIKE LINE OF bdctab,
messtab TYPE TABLE OF bdcmsgcoll,
wa2 LIKE LINE OF messtab,
d_mode(1) TYPE c,
d_update(1) TYPE c,
session(12) TYPE c,
date TYPE dats,
message(73) TYPE c.
PARAMETERS: ct RADIOBUTTON GROUP radi,
mode LIKE d_mode DEFAULT 'A',
update LIKE d_update DEFAULT 'A',
bi RADIOBUTTON GROUP radi,
ses_name LIKE session DEFAULT 'CUST',
k_date LIKE date DEFAULT sy-datum,
k_sess AS CHECKBOX DEFAULT 'X'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\aaa.txt'
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = 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.
IF ct = 'X'.
PERFORM call_transaction.
ELSE.
PERFORM batch_input.
ENDIF.
&----
*& Form CALL_TRANSACTION
&----
text
----
--> p1 text
<-- p2 text
----
FORM call_transaction .
LOOP AT itab INTO wa.
REFRESH bdctab.
REFRESH messtab.
PERFORM bdc.
CALL TRANSACTION 'XD01' USING bdctab
MODE mode
UPDATE update
MESSAGES INTO messtab.
LOOP AT messtab INTO wa2.
SELECT SINGLE text INTO message
FROM t100
WHERE arbgb = wa2-msgid
AND msgnr = wa2-msgnr
AND sprsl = 'EN'.
IF sy-subrc = 0.
REPLACE '&' IN message WITH wa2-msgv1.
WRITE:/ message.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. " CALL_TRANSACTION
&----
*& Form BDC
&----
text
----
--> p1 text
<-- p2 text
----
FORM bdc .
SCREEN 1
PERFORM bdc_dynpro USING 'SAPMF02D' '0100'.
PERFORM bdc_field USING 'RF02D-KTOKD' wa-ktokd.
PERFORM bdc_field USING 'RF02D-KUNNR' wa-kunnr.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
SCREEN 2
PERFORM bdc_dynpro USING 'SAPMF02D' '0110'.
PERFORM bdc_field USING 'KNA1-NAME1' wa-name1.
PERFORM bdc_field USING 'KNA1-SORTL' wa-sortl.
PERFORM bdc_field USING 'KNA1-ORT01' wa-ort01.
PERFORM bdc_field USING 'KNA1-LAND1' wa-land1.
PERFORM bdc_field USING 'KNA1-SPRAS' wa-spras.
PERFORM bdc_field USING 'KNA1-PSTLZ' wa-pstlz.
PERFORM bdc_field USING 'KNA1-LZONE' wa-lzone.
PERFORM bdc_field USING 'BDC_OKCODE' '=UPDA'.
ENDFORM. " BDC
&----
*& Form bdc_dynpro
&----
text
----
-->P_0294 text
-->P_0295 text
----
FORM bdc_dynpro USING program
dynpro.
CLEAR wa1.
wa1-program = program.
wa1-dynpro = dynpro.
wa1-dynbegin = 'X'.
APPEND wa1 TO bdctab.
ENDFORM. " bdc_dynpro
&----
*& Form bdc_field
&----
text
----
-->P_0299 text
-->P_0300 text
----
FORM bdc_field USING fnam
fval.
IF fval <> space.
CLEAR wa1.
wa1-fnam = fnam.
wa1-fval = fval.
APPEND wa1 TO bdctab.
ENDIF.
ENDFORM. " bdc_field
&----
*& Form BATCH_INPUT
&----
text
----
--> p1 text
<-- p2 text
----
FORM batch_input .
PERFORM bdc_open.
LOOP AT itab INTO wa.
REFRESH bdctab.
PERFORM bdc.
PERFORM bdc_insert.
ENDLOOP.
PERFORM bdc_close.
ENDFORM. " BATCH_INPUT
&----
*& Form BDC_OPEN
&----
text
----
--> p1 text
<-- p2 text
----
FORM bdc_open .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = ses_name
holddate = k_date
keep = k_sess
user = sy-uname
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
OTHERS = 11.
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. " BDC_OPEN
&----
*& Form BDC_INSERT
&----
text
----
--> p1 text
<-- p2 text
----
FORM bdc_insert .
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'XD01'
TABLES
dynprotab = bdctab
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7.
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. " BDC_INSERT
&----
*& Form BDC_CLOSE
&----
text
----
--> p1 text
<-- p2 text
----
FORM bdc_close .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_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.
ENDFORM. " BDC_CLOSE
<b>Reward if helpful,</b>
Regards,
Adithya M.
08-21-2007 2:43 PM
Why do you want to use BDC for VA01, use standard sap bapi "BAPI_SALESORDER_CREATEFROMDAT2" to create sales order.
08-21-2007 2:46 PM
Use transaction SHDB :
Process the transaction.
Save the result
Choose the Generate Program button - Save it as a Z program.
Now edit the generated code to suit your requirements.
Andrew