Gary Guo

Learning never ends


  • Home

  • About

  • Tags

  • Categories

  • Archives

  • Sitemap

  • Search

How to send material master delta updates to external system by change pointer

Posted on 2018-03-12 | In SAP

In this guide, I will share the steps about how to use change pointer to send the material master delta updates to external system. For demo purpose, I will write the IDOC to SAP application server file system with XML file format.

System: ECC

Release: 740

Create message type (t-code: WE81)

Create message type ZMATMAS_DIST via t-code WE81. Use any short text you like

Link message type with IDOC type (t-code: WE82)

Link the message type ZMATMAS_DIST with standard IDOC type MATMAS05 and release 740

Make sure the change pointer is activated globally (t-code: BD61)

Run t-code BD61 to make sure the change pointer is activated globally

Make sure the change pointer is activated for the message type (t-code: BD50)

Run t-code BD50, and add a new table entry for ZMATMAS_DIST. Select the active checkbox

Maintain the change pointer table fields for the message type (t-code: BD52)

Run t-code BD52, input change pointer ZMATMAS_DIST, and input the table fields for which change pointer will be created. If one table field is specified here, the change pointer with the message type ZMATMAS_DIST will be created when the field value is changed.

  • Object: MATERIAL
  • Table name: MARA, MARC, DMAKT, etc
  • Field name: MEINS, MATKL, NTGEW, KEY

When KEY is used as field name, the change pointer will be created when a new table record is created/deleted.

Create a logical system if necessary (t-code: BD54)

Create a new logical system LS_DIST. You can reuse your existing logical system as well.

Add the message type to distribution model (t-code: BD64)

Run t-code BD64. Switch to Edit mode. Choose Create Model View to create a new model view E4D. You can reuse your existing model view as well.

Choose Add Message Type to add one distribution record with message type ZMATMAS_DIST, sender E4DCLNT100, which is the logical system of current SAP system specified in t-code SCC4, receiver LS_DIST

Create a XML file port (t-code: WE21)

Create a XML file port XMLPORT via t-code WE21. Choose Physical directory, choose the directory like \usr\sap\tmp\, and choose EDI_PATH_CREATE_MESTYP_DOCNUM as the function to generate file name

Maintain the partner profile (t-code: WE20)

Run t-code WE20, create the partner profile for the logical system LS_DIST. Save the partner profile, click Create outbound parameters button to add the outbound parameters for message type ZMATMAS_DIST. Use receiver port XMLPORT, basic type MATMAS05, output mode Transfer IDoc immediately

Maintain the additional data for message type (t-code: BD60)

Run t-code BD60. Copy the record MATMAS to a new record ZMATMAS_DIST, and deselect the checkbox Reducable Message Type. The format function module MASTERIDOC_CREATE_SMD_MATMAS is used to create material IDOC from change pointer.

Update material master data (t-code: MM02)

Run t-code MM02, input material P-100, choose view Basic Data 1, change the gross weight and save the change

Check the change pointer in BDCP2 (t-code: SE16)

Run t-code SE16, input table BDCP2, input message type ZMATMAS_DIST and execute the program. You will see that a new change pointer with message type ZMATMAS_DIST and blank processing status is generated.

Create IDOC from change pointer (t-code: BD21)

Run t-code BD21 or run program RBDMIDOC manually. You can schedule the program as periodical batch job as well. Input message type ZMATMAS_DIST and execute the program. You will get the information message saying that # IDOC created and generated for the message type ZMATMAS_DIST.

Run t-code SE16, and check the previous change pointer. You will see that the change pointer processing status is changed to X.

Check the new generated IDOC (t-code: WE02)

Run t-code WE02, input the message type ZMATMAS_DIST and execute. You will see the new generated IDOC.

Check the XML file generated (t-code: AL11)

Run t-code AL11, open the directory \usr\sap\tmp\. You will see that a XML file ZMATMAS_DI_02496857.xml was created. Open the file, and you will see the IDOC XML file details.

GitHub website setup with Hexo in Windows

Posted on 2018-03-06 | In Website

If you want to set up a GitHub website with Hexo in Windows, and you need your website set up with basic functionality, like tags, categories, about, search, theme, visitor count, comments and etc, you can follow the below guide.

Steps

  1. Set up the account and repository in GitHub
  2. Install Git
  3. Install Node.js
  4. Install Hexo
  5. Hexo basic commands
  6. Hexo folder structure and basic setup
  7. Change Hexo theme
  8. About Markdown
  9. Link to a local image
  10. Add the pages: tags, categories
  11. Add the page: about me
  12. Add search functionality
  13. Create a new post
  14. Deploy to GitHub
  15. Count of Visitors
  16. Add comments for website
  17. Errors & Tips
  18. Links & References

Set up the account and repository in GitHub

Create an account in https://github.com/, click on the Create New button in the left upper corner, choose New Repository.

In the Repository name, input [your_GitHub_account].github.io such as “gary5496.github.io”, select the checkbox Initialize this repository with a README, and click on button Create repository.

In the home page of the new repository, choose tab Settings. In the GitHub Pages section, change Source from None to master branch, and click on Save button next to it.

Install Git

Git is the tool to manage your repository on GitHub.

Download the Git from https://git-scm.com/download/win, and install it.

After installation, right click on any folder, and choose Git Bash Here to open Git Bash. To bind your GitHub account and email to the Git tool on your local computer, run the below commands.

git config --global user.name [your GitHub account]
git config --global user.email [your GitHub email address]

Install Node.js

Hexo is a framework based on Node.js.

Download Node.js from https://nodejs.org/en/download/, and install it. Run the below command to validate the Node.js status after installation.

node -v

npm is the package manager for JavasSript. Run the below command to check the npm status.

npm -v

Install Hexo

Hexo is a framework which is helpful to build a blog. See https://hexo.io/ for details.

Create a folder as the base folder for Hexo. Run cmd command, run cd to change the folder to the Hexo base folder, and run the below command to install Hexo.

npm install -g hexo-cli 

Run the below command to install Hexo Git deployer

npm install hexo-deployer-git --save

Run the below command to initialize Hexo

hexo init

Hexo basic commands

Initialize Hexo after installation

hexo init

Start Hexo server. You can stop the server by pressing Ctrl + C.

hexo server
hexo s

After the server start, open the below link in browser, and you can see the initial page for Hexo

http://localhost:4000/

Create a new page, like tags, categories, about me, etc

hexo new page [page_name]

Create a new post

hexo new [post_name]
hexo n [post_name]

Generate the website for .md files

hexo generate
hexo g

Deploy the website to GitHub

hexo deploy
hexo d

Generate the website for .md files and deploy the website to GitHub

hexo deploy --generate
hexo d -g

Clean the cache. It may be necessary after the change on a post, a page or a configuration file.

hexo clean

Hexo folder structure and basic setup

  • node_modules: the folder to save Node.js modules for Hexo
  • themes: the folder for themes
  • source: the folder to save the source markdown (.md) files
  • scaffolds: the folder for templates
  • public: the folder to save the HTML pages after generation
  • _config.yml: the root configuration file
  • themes/[theme_name]/_config.yml: the theme configuration file
  • source/_posts: the folder to save the post markdown (.md) files

Update the root configuration file for the below parameters

1
2
3
4
5
6
url: https://gary5496.github.io/

highlight:
enable: true
line_number: true
auto_detect: true

Change Hexo theme

Check the Hexo themes from https://hexo.io/themes/.

For example, if you want to download the Next theme and use it, follow the below steps.

a. Run the below command to download the Next theme to themes folder.

git clone https://github.com/theme-next/hexo-theme-next themes/next

b. Change the theme parameter to next in the root configuration file

1
theme: next

c. Change the parameters in the theme configuration file to use another scheme and add social links if necessary.

1
2
3
scheme: Gemini

highlight_theme: night

d. Update the file custom.styl under folder \themes\next\source\css\_custom, and change the parameter as below

// Custom styles.

code {
  color: #098;
}

About Markdown

Markdown is a text-to-HTML formatting syntax for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). See https://www.appinn.com/markdown/ for Markdown syntax details.

Here is some common syntax.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
*italic text*

**bold text**

***

<http://www.url.com>
[url tile](url address)

### header 3

- list item 1
- list item 2

text before `small code block` text after

![Alt text](/path/to/img.jpg)

code block line 1
code block line 2

You can choose a Markdown editor like MarkdownPad to edit Markdown files. Download it from http://www.markdownpad.com/ and install it. The editor has a preview functionality which is very helpful for editing.

Install Awesomium 1.6.6 SDK from http://markdownpad.com/download/awesomium_v1.6.6_sdk_win.exe and restart the computer, if LivePreview is not working for MarkdownPad and the error message is This view has crashed!

Link to a local image

Update the root configuration file as below. After the configuration change, there will be a folder created when using command hexo new [post_name] to create a new post, and the folder name will be the same as post name.

1
post_asset_folder: true

You can copy your image file to the post folder, and use the below Markdown syntax to add an image in a post. With this approach, the image will be showing in the post, but it is not showing in the home page.

1
![alt_text](image_name.jpg)

You can install the below package and then use the below Markdown syntax to add an image to a post, and the image will be showing in both the post and home page.

npm install https://github.com/CodeFalling/hexo-asset-image --save
1
{% asset_img image_name.jpg This is an image %}

Add the pages: tags, categories

Update the root configuration file for the directories.

1
2
tag_dir: tags
category_dir: categories

Update the theme configuration file for the menu parameter.

1
2
3
menu:
tags: /tags/ || tags
categories: /categories/ || th

Run the below command to create the page for tags

hexo new page tags

Update the file \source\tags\index.md

---
title: tags
date: 2018-03-06 14:38:05
type: "tags"
comments: false
---

Run the below command to create the page for categories

hexo new page categories

Update the file \source\categories\index.md

---
title: categories
date: 2018-03-06 14:39:05
type: "categories"
comments: false
---

Add the page: about me

Update the theme configuration file for the menu parameter.

1
2
menu:
about: /about/ || user

Run the below command to create the page for about

hexo new page about

Update the file \source\about\index.md

---
title: about me
date: 2018-03-06 14:19:41
---
### About me

This is my blog.

Add search functionality

Install the Hexo search package via the below command

npm install hexo-generator-searchdb --save

Add the below parameters to root configuration file.

1
2
3
search:
path: search.xml
field: post

Change the below parameter in theme configuration file.

1
2
local_search:
enable: true

Create a new post

Run the below command to create a new post

hexo new [post_name]

Update the file \source\_post\[post_name].md. See below for example.

1
2
3
4
5
6
7
8
9
10
11
---
title: Hello World
date: 2018-03-06 14:19:41
tags: [Windows]
categories: Windows
---
###Hello

Hello! This is my first blog.

printf("Hello world!");

Deploy to GitHub

If you are using HTTP to deploy your website to GitHub, you may get a pop-up dialog to input your GitHub account and password when running command hexo deploy during deployment.

In this case, the root configuration file is configured as below.

1
2
3
4
5
6
deploy:
type: git
repo: https://github.com/gary5496/gary5496.github.io.git
name: gary5496
email: gary5496@163.com
branch: master

If you are using SSH to deploy your website to GitHub, you can follow the below steps.

a. Run the below command via Git Bash to generate a key pair.

ssh-keygen -t rsa -C "your_GitHub_email_address"

b. Use the default file path C:/User/[Windows_account]/.ssh/, and input the passphrase if necessary

c. Open the file C:/User/[Windows_account]/.ssh/id_rsa.pub, and copy the entire file content

d. Log on to GitHub, click on Avatar on the left upper corner, choose Settings, choose SSH and GPG Keys, click on button New SSH Key, input the Title with any value, paste the entire file content from last step as Key, and click on button Add SSH Key

e. If the passphrase is not empty in the step b, and you don’t want to reenter your passphrase every time you use your SSH key, you can run the below commands to add your key to the SSH agent, which manages your SSH keys and remembers your passphrase.

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

f. Run the below command via Git Bash to check the SSH connection

ssh -T git@github.com

The successful result should be like below.

Hi gary5496! You’ve successfully authenticated, but GitHub does not provide shell access.

g. Run the below command to deploy website to GitHub

hexo deploy

In this case, the root configuration file is configured as below.

1
2
3
4
deploy:
type: git
repo: git@github.com:gary5496/gary5496.github.io.git
branch: master

Count of Visitors

Open the theme configuration file and update the parameters as below

1
2
3
4
5
6
7
8
busuanzi_count:
enable: true
total_visitors: true
total_visitors_icon: user
total_views: true
total_views_icon: eye
post_views: true
post_views_icon: eye

Add comments for website

Create a new GitHub repository website_comments to save the comments for the website

Request a GitHub OAuth application via the link https://github.com/settings/applications/new, or via navigation by GitHub homepage -> Avatar on the left upper corner -> Settings -> Developer Settings -> OAuth Apps -> Request a new application. Input the parameters as below, and register application

Application name: website_comments

Homepage URL: https://gary5496.github.io/

Authorization callback URL: https://gary5496.github.io/

Note down the Client ID and Client Secret on the application page.

Update the theme configuration file to add the below parameters

1
2
3
4
5
6
7
8
9
gitalk:
enable: true
clientID: [above_client_id]
clientSecret: [above_client_secret]
repo: website_comments
owner: gary5496
admin: gary5496
distractionFreeMode: true # Facebook-like distraction free mode
createIssueManually: false

Create a file gitalk.swig under folder next/layout/_third-party/comments. See below for the file content.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{% if theme.gitalk.enable %}
{% if page.comments %}
<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script type="text/javascript">
const gitalk = new Gitalk({
clientID: '{{theme.gitalk.clientID}}',
clientSecret: '{{theme.gitalk.clientSecret}}',
repo: '{{theme.gitalk.repo}}',
owner: '{{theme.gitalk.owner}}',
admin: '{{theme.gitalk.admin}}'.split(','),
id: location.pathname,
// facebook-like distraction free mode
distractionFreeMode: '{{ theme.gitalk.distractionFreeMode }}',
createIssueManually: '{{ theme.gitalk.createIssueManually }}'
})
gitalk.render('gitalk-container')
</script>
{% endif %}
{% endif %}

Update the file index.swig under folder next/layout/_third-party/comments to add the below code

1
{% include 'gitalk.swig' %}

Update the file comments.swig under folder next/layout/_partials to add the below code

1
2
{% elseif theme.gitalk.distractionFreeMode %}  
<div id="gitalk-container"></div>

Errors & Tips

Error message:

After the change on a post, a page or a configuration file, the change is not reflected on the site.

Solution:

Clean the cache by running the command hexo clean

Error message:

The LivePreview functionality is not working for MarkdownPad editor. The error message is The view has crashed!.

Solution:

Install Awesomium 1.6.6 SDK from this link and restart the computer

Error message:

If you are using SSH to deploy your Hexo contents to GitHub, you got an error message Could not read from remote repository when you are running the command hexo deploy to deploy the site to GitHub via cmd.

Solution:

Use Git Bash to run the command, instead of cmd

Links & References

  • https://zhuanlan.zhihu.com/p/26625249
  • https://codezjx.github.io/2017/07/31/hexo-guide/
  • http://theme-next.iissnan.com/theme-settings.html
  • http://theme-next.iissnan.com/third-party-services.html#analytics-system
  • https://yanyinhong.github.io/2017/05/02/How-to-insert-image-in-hexo-post/
  • https://univer2012.github.io/2017/04/23/6how-to-insert-picture-in-hexo-blog/
  • https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
  • https://www.jianshu.com/p/9be29ed2f4b7
  • https://blog.maple3142.net/2017/11/04/hexo-next-readcount/#group-7

Excel Tips

Posted on 2018-03-06 | In Windows

Below are some tips for Microsoft Excel collected during my daily work, which may be helpful for you.

Add leading zeros to a numeric value

=TEXT(A1,"0000000000")

Add leading zeros to any value

=RIGHT(REPT("0",10)&A2,10)

The symbol & will be used to concatenate the strings. The function REPT will repeat the character for times specified.

Look up a value from a range

G5=VLOOKUP("string",B2:F200,2,FALSE)

The above example will look up the value string from the first column B and the current row 5 of the range B2:F206, and the value of C5, which is specified by the 3rd parameter 2, will be returned. The fourth parameter FALSE means exact match.

Convert an error value to blank

=IFERROR(VLOOKUP(B251,A$1:I$360,8,FALSE),"")

Since the VLOOKUP function may return an error value if the look-up is failed, we can use the IFERROR function to convert the error value to blank.

Get a substring from a string

=MID(C2,2,3)

The above example will get the substring from string C2. It will begin at the second position, and the length will be 3.

Summarize the value by some conditions

=SUMIFS(A:A,B:B,">10", B:B,"<20")

The above example will summarize the values for A column, when the value in column B is greater than 10 and less than 20.

1…45

Gary Guo

23 posts
9 categories
19 tags
Links
  • Markdown Cheatsheet
  • JSFiddle
  • JavaScript - Liao XueFeng
  • Git - Liao XueFeng
  • Blog - Ruan YiFeng
© 2018 Gary Guo
Powered by Hexo
|
Theme — NexT.Gemini v6.0.5