jueves, 23 de diciembre de 2010

Abap que crea script VBS

*Manda pulsaciones de teclas como si el usuario las invocara, llena la XD02

report zbatchxd02.
data begin of i_upload occurs 0.
data line(255).
data end of i_upload.

parameter p_name like rlgrap-filename.

data begin of i_outtab occurs 0.
data line(255).
data end of i_outtab.

data: begin of record,
customer(100),
name(100),
name2(100),
name3(100),
name4(100),
street(100),
street2(100),
housenumber(100),
house(100),
nosuppl(100),
district(100),
street3(100),
street4(100),
city(100),
region(100),
postalcode(100),
country(100),
telephone1(100),
taxcode1(100),
taxcode2(100),
zipcode(100),
end of record.


*$*$********************************************************************
*$*$ AT SELECTION-SCREEN
*$*$********************************************************************
at selection-screen.

* Para la seleccion del archivo a convertir
at selection-screen on value-request for p_name.
call function 'KD_GET_FILENAME_ON_F4'
exporting
program_name = syst-repid
dynpro_number = syst-dynnr
field_name = ''
static = ''
mask = ''
changing
file_name = p_name
exceptions
mask_too_long = 1
others = 2.

*$*$********************************************************************
*$*$ START-OF-SELECTION
*$*$********************************************************************
start-of-selection.
perform leer_archivo.
perform procesa_datos.
perform baja_script.
*Perform BATCHINPUT.

*$*$********************************************************************
*$*$ FORMS
*$*$********************************************************************
*&---------------------------------------------------------------------*
*& Form LEER_ARCHIVO
*&---------------------------------------------------------------------*
form leer_archivo.

* Para cargar el archivo de entrada
refresh i_upload.
call function 'WS_UPLOAD'
exporting
filename = p_name
* Filetype = 'WK1'
tables
data_tab = i_upload
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10.

endform. " LEER_ARCHIVO

*&---------------------------------------------------------------------*
*& Form PROCESA_DATOS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form procesa_datos.
clear: record.
data: c_tab type x value '09'.
loop at i_upload.
translate i_upload-line using '" '.
condense i_upload-line.
modify i_upload.
endloop.
i_outtab-line = 'set WshShell = WScript.CreateObject("WScript.Shell")'.
append i_outtab.

loop at i_upload.
split i_upload-line at c_tab into
record-customer
record-name
record-name2
record-name3
record-name4
record-street
record-street2
record-housenumber
record-nosuppl
record-district
record-street3
record-street4
record-city
record-region
record-postalcode
record-country
record-telephone1
record-taxcode1
record-taxcode2
record-zipcode.

condense: record-customer
,record-name
,record-name2
,record-name3
,record-name4
,record-street
,record-street2
,record-housenumber
,record-nosuppl
,record-district
,record-street3
,record-street4
,record-city
,record-region
,record-postalcode
,record-country
,record-telephone1
,record-taxcode1
,record-taxcode2
,record-zipcode.

i_outtab-line = 'WScript.Sleep 3500'.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys
"{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{
del}{del}"'.
append i_outtab.
*CUSTOMER
concatenate 'WshShell.SendKeys "' record-customer '"' into i_outtab-line
. append i_outtab.
*ENTER
i_outtab-line = 'WshShell.SendKeys "~"'.
append i_outtab.
i_outtab-line = 'WScript.Sleep 1500'.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.




*NAME1
concatenate 'WshShell.SendKeys "' record-name '"' into i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*NAME2
concatenate 'WshShell.SendKeys "' record-name2 '"' into i_outtab-line.
append i_outtab.
*PREGUNTAMOS SI ES DE 2 RENGLONES
i_outtab-line = 'intAnswer = Msgbox("¿Es de 2 campos?", vbYesNo,
"Script")'.
append i_outtab.
i_outtab-line = 'If intAnswer = vbYes Then'.
append i_outtab.

i_outtab-line = 'WshShell.SendKeys "{TAB}{TAB}{TAB}"'.
append i_outtab.
i_outtab-line = 'Else'.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}{DEL}{TAB}{TAB}{TAB}"'.
append i_outtab.
i_outtab-line = 'End If'.
append i_outtab.


*STREET
concatenate 'WshShell.SendKeys "' record-street '"' into i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*HOUSE NUMBER
concatenate 'WshShell.SendKeys "' record-housenumber '"' into
i_outtab-line. append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*POSTAL CODE
concatenate 'WshShell.SendKeys "' record-postalcode '"' into
i_outtab-line. append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*CITY
concatenate 'WshShell.SendKeys "' record-city '"' into
i_outtab-line. append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*DISTRICT
i_outtab-line = 'WshShell.SendKeys"{DEL}"'.append i_outtab.
concatenate 'WshShell.SendKeys "' record-district '"' into
i_outtab-line. append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*MANDA ESPACIO Y ESPERA
i_outtab-line = 'WshShell.SendKeys " "'.
append i_outtab.
i_outtab-line = 'WScript.Sleep 1500'.
append i_outtab.
*NAME3

concatenate 'WshShell.SendKeys "' record-name3 '"' into i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.

*NAME4
concatenate 'WshShell.SendKeys "' record-name4 '"' into i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}{TAB}"'.
append i_outtab.
*HOUSENOSUPPLY
concatenate 'WshShell.SendKeys "' record-nosuppl '"' into i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*STREET3
concatenate 'WshShell.SendKeys "' record-street3 '"' into i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*STREET4
concatenate 'WshShell.SendKeys "' record-street4 '"' into i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys
"{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}"'.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys " "'.
append i_outtab.
i_outtab-line = 'WScript.Sleep 1500'.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
*REGION
*concatenate 'WshShell.SendKeys "' record-region '"' into i_outtab-line.
* append i_outtab.
i_outtab-line = 'WshShell.SendKeys
"{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}"'.
append i_outtab.
*Telephone1
*concatenate 'WshShell.SendKeys "' record-telephone1 '"' into
*i_outtab-line.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{F8}"'.
append i_outtab.
i_outtab-line = 'WScript.Sleep 1500'.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}"'.
append i_outtab.

*Taxcode1
concatenate 'WshShell.SendKeys "' record-taxcode1 '"' into i_outtab-line
.
append i_outtab.
i_outtab-line = 'WshShell.SendKeys "{TAB}"'.
append i_outtab.

*Taxcode2
concatenate 'WshShell.SendKeys "' record-taxcode2 '"' into i_outtab-line
.
i_outtab-line = 'MsgBox "¿Grabar ahora?"'.
append i_outtab.
i_outtab-line = 'WScript.Sleep 2500'.

i_outtab-line = 'WshShell.SendKeys "^s"'.
append i_outtab.

clear i_outtab.
append i_outtab.

endloop.

endform. " PROCESA_DATOS

*&---------------------------------------------------------------------*
*& Form BAJA_SCRIPT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form baja_script.
concatenate p_name '.vbs' into p_name.
call function 'WS_DOWNLOAD'
exporting
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
filename = p_name
* FILETYPE = 'DAT'
* filetype = 'WK1'
* MODE = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* importing
* filelength =
tables
data_tab = i_outtab
* FIELDNAMES =
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
others = 8.

if sy-subrc = 0.
skip.
write:/ 'Script bajado'.
endif.
endform. " BAJA_SCRIPT

viernes, 17 de diciembre de 2010

obtener clave de oss marketplace

obtener clave de oss marketplace
te vas a service.sap.com
luego en la opcion keys and requests
luego sscrkeys llenas con los datos de la pantalla
de sap y luego das register y con eso te manda la
clave

Enviar mensajes abap

para enviar un mensaje usa
con popup
message i368(00) with 'test la hora es ' sy-uzeit.
en la barra de estado
Message S000(IH) with 'Terminado'.
Message e368(00) with 'No se encontró Pedido'.

permite varios parametros creo que 4 mensajes seguidos.

martes, 7 de diciembre de 2010

Write Abap con colores disponibles

REPORT ZCOLOR LINE-SIZE 90 NO STANDARD PAGE HEADING.

DATA: BEGIN OF TP OCCURS 10, ID, NR(8), TEXT(255), END OF TP.

DATA: LENGTH TYPE I VALUE 8, " Length of list
TESTSTRING(15) TYPE C VALUE '012345678901234',
WIDTH TYPE I. " Width of list
DATA: TXT_REPORT LIKE DOKHL-OBJECT.


START-OF-SELECTION.
PERFORM HEADING.
PERFORM OUTPUT_BODY.

FORM HEADING.
FORMAT INTENSIFIED OFF. " Remove any INTENSIFIED
ULINE AT (WIDTH). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED." Title color
WRITE: / SY-VLINE. " Left border
WRITE: 'No |Colour |intensified |intensified off|',
'inverse' NO-GAP.
WRITE: AT WIDTH SY-VLINE. " Right border
ULINE AT (WIDTH). " Line below titles
FORMAT COLOR OFF.
ENDFORM.

FORM OUTPUT_BODY.

DO LENGTH TIMES.
PERFORM WRITE_LINE USING SY-INDEX.
ENDDO.
ENDFORM.

FORM WRITE_LINE USING COUNT TYPE I.
DATA: HELP(14) TYPE C,
COUNT1 TYPE I.

COUNT1 = SY-INDEX - 1.
WRITE: / SY-VLINE NO-GAP.
WRITE: (4) COUNT1 COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
CASE COUNT1.
WHEN '0'.
HELP = 'COL_BACKGROUND'.
WHEN '1'.
HELP = 'COL_HEADING'.
WHEN '2'.
HELP = 'COL_NORMAL'.
WHEN '3'.
HELP = 'COL_TOTAL'.
WHEN '4'.
HELP = 'COL_KEY'.
WHEN '5'.
HELP = 'COL_POSITIVE'.
WHEN '6'.
HELP = 'COL_NEGATIVE'.
WHEN '7'.
HELP = 'COL_GROUP'.
ENDCASE.
WRITE: HELP COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED OFF NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INVERSE NO-GAP.
WRITE AT WIDTH SY-VLINE NO-GAP.
ENDFORM.

Verificar disponibilidad de un material

REPORT ZEX_AVAILIBILITYCHK .

Parameter: p_matnr like BAPIMATVP-MATNR,
p_werks like BAPIMATVP-WERKS,
p_unit like BAPIADMM-UNIT.

*Data: int_wmdvsx like BAPIWMDVS occurs 0 with header line,
* int_wmdvex like BAPIWMDVE occurs 0 with header line.

Data: int_wmdvsx type table of bapiwmdvs with header line,
int_wmdvex type table of bapiwmdve with header line,
d_WKBST like BAPICM61V-WKBST.



CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
EXPORTING
PLANT = p_werks
MATERIAL = p_matnr
UNIT = p_unit
* CHECK_RULE =
* STGE_LOC =
* BATCH =
* CUSTOMER =
* DOC_NUMBER =
* ITM_NUMBER =
* WBS_ELEM =
* STOCK_IND =
* DEC_FOR_ROUNDING =
* DEC_FOR_ROUNDING_X =
* READ_ATP_LOCK =
* READ_ATP_LOCK_X =
IMPORTING
* ENDLEADTME =
AV_QTY_PLT = d_WKBST
* DIALOGFLAG =
* RETURN =
TABLES
WMDVSX = int_wmdvsx
WMDVEX = int_wmdvex
.


Write:/ d_WKBST.

If sy-subrc = 0.

endif.