SAPNWRFC Connection how to WRITE DATA php

大兔子大兔子 提交于 2019-12-07 23:40:00

问题


Below code used to fetch and display data from PHP

<?php
use SAPNWRFC\Connection as SapConnection;
use SAPNWRFC\Exception as SapException;
//print_r($_POST);
$config = [
    'ashost' => '###.###.###.###',
    'sysnr'  => '##',
    'client' => '###',
    'user'   => '####',
    'passwd' => '*******',
    'trace'  => SapConnection::TRACE_LEVEL_OFF
];
$sap = false;
$sapMTList = "";
try {
    $sap = new SapConnection($config);
    $result=$sap->getFunction("ZBAPI_SAMPLE_LIST_V1");
    $parms = [
       // 'I_MATTYPE' => 'FERT', 'I_PLANT' => 'XXXX'
        "I_MATTYPE" => "FERT", "I_PLANT" => "XXXX"
        ];
    if(isset($_POST['submit']) && $_POST['submit'] === 'sap_params'){
        $plantNumber="";
        if(isset($_POST['plantNumber'])){
            $plantNumber=$_POST['plantNumber'];
        }
        $parms = [
            "I_MATTYPE" => "FERT", "I_PLANT" => "$plantNumber"
        ];
    }
    $test = $result->invoke( $parms);
    $sapMTList = array_shift($test);
} catch(SapException $ex) {
    echo 'Exception: ' . $ex->getMessage() . PHP_EOL;
}

?>
<?php
 if($sapMTList != "" && !empty($sapMTList)){
        $i=0;
        foreach ($sapMTList as $column){
          // displays data
       }
?>

The code works fantastic to read data. ref: https://gkralik.github.io/php7-sapnwrfc/introduction.html

Can anyone tell me how to write data?

Tried my level best to find resource but couldn't find anywhere. Any help would be highly appreciated. Thanks in advance.

Forgot to mention i use:

PHP Version 7.0.21

SAPNWRFC VERSION Version 1.1.2

SAP NW RFC SDK 7200.0.33

iis server (in 2k12)

Hi used below code got success message but null value in sap

$INputParams = [
    'MATNR'=>'12345678.02',
    'WERKS'=>'1000',
    'KTEXT'=>'Men in Black 2',
    'LAEDA'=>'20170907',
    'MTART'=>'FERT',
    'MATKL'=>'01',
    'MEINS'=>'KARMA',
    'EKGRP'=>'002',
    'DISMM'=>'PD',
    'BKLAS'=>'7920',
    'VPRSV'=>'S',
    'PREIS'=>123.45,
    'WAERS'=>'AED',
    'PEINH'=>1,
    'ERNAM'=>'SAP01'
  ];

$parms = [
       // 'I_MATTYPE' => 'FERT', 'I_PLANT' => '1000'
        "IT_MATERILALS" => ['defaultValue' => $INputParams]
        ];

$test = $result->invoke( $parms);

print_r($test);

/////// GOT OUTPUT

Array
(
    [RETURN] => Array
        (
            [TYPE] => S
            [ID] => ZMM                 
            [NUMBER] => 100
            [MESSAGE] => Successfully Updated                                                                                                                                                                                                        
            [LOG_NO] =>                     
            [LOG_MSG_NO] => 000000
            [MESSAGE_V1] =>                                                   
            [MESSAGE_V2] =>                                                   
            [MESSAGE_V3] =>                                                   
            [MESSAGE_V4] =>                                                   
            [PARAMETER] =>                                 
            [ROW] => 0
            [FIELD] =>                               
            [SYSTEM] =>           
        )

    [IT_MATERILALS] => Array
        (
            [0] => Array
                (
                    [MATNR] => 12345678.02
                    [WERKS] => 1000
                    [KTEXT] => Men in Black 2                         
                    [LAEDA] => 20170907
                    [MTART] => FERT
                    [MATKL] => 01       
                    [MEINS] => KARMA
                    [EKGRP] => 002
                    [DISMM] => PD
                    [BKLAS] => 7920
                    [VPRSV] => S
                    [PREIS] => 123.45
                    [WAERS] => AED  
                    [PEINH] => 1
                    [ERNAM] => SAP01       
                )

        )

)

//////

When i check in SAP GUI record with null values is saved.

Can anyone help?

来源:https://stackoverflow.com/questions/48962760/sapnwrfc-connection-how-to-write-data-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!